/* ========================================================================
   FB Evidence Review — Professional Legal Tool Theme
   ======================================================================== */

/* --- Fonts --- */

/* --- Tokens: Light theme (default) --- */
:root, [data-theme="light"] {
  --navy:       #1B2A4A;
  --navy-light: #2C3E5E;
  --slate:      #475569;
  --slate-light:#94A3B8;
  --border:     #E2E8F0;
  --border-dark:#CBD5E1;
  --bg:         #FFFFFF;
  --bg-soft:    #F8FAFC;
  --bg-warm:    #FFFBEB;
  --text:       #0F172A;
  --text-muted: #64748B;
  --blue:       #2563EB;
  --blue-light: #DBEAFE;
  --red:        #DC2626;
  --red-light:  #FEE2E2;
  --green:      #16A34A;
  --green-light:#DCFCE7;
  --amber:      #D97706;
  --amber-light:#FEF3C7;
  --radius:     6px;
  --radius-lg:  10px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --font:       'Segoe UI', 'Helvetica Neue', Arial, system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-size-base: 14px;
  --ui-scale: 1;
  --transition: 150ms ease;
}

/* --- Tokens: Dark theme --- */
[data-theme="dark"] {
  --navy:       #0F1729;
  --navy-light: #1E293B;
  --slate:      #94A3B8;
  --slate-light:#64748B;
  --border:     #334155;
  --border-dark:#475569;
  --bg:         #1E293B;
  --bg-soft:    #0F172A;
  --bg-warm:    #422006;
  --text:       #E2E8F0;
  --text-muted: #94A3B8;
  --blue:       #60A5FA;
  --blue-light: #1E3A5F;
  --red:        #F87171;
  --red-light:  #450A0A;
  --green:      #4ADE80;
  --green-light:#052E16;
  --amber:      #FBBF24;
  --amber-light:#451A03;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow:     0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg-soft);
  color: var(--text);
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app-shell {
  zoom: var(--ui-scale);
}
@supports not (zoom: 1) {
  .app-shell {
    transform: scale(var(--ui-scale));
    transform-origin: top left;
    width: calc(100% / var(--ui-scale));
  }
}
body.modal-open { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* --- Top Navigation --- */
.site-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1200;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.site-brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
  letter-spacing: -.01em;
  color: #fff;
  margin-right: 32px;
  white-space: nowrap;
  text-decoration: none;
}
.site-brand:hover { text-decoration: none; opacity: .9; }
.site-brand { display:inline-flex; align-items:center; gap:10px; }
.site-brand-logo { width:34px; height:34px; border-radius:10px; box-shadow: 0 6px 14px rgba(0,0,0,.28); flex:0 0 auto; }
.site-brand-wordmark { display:inline-block; }
.dashboard-brand { display:flex; align-items:center; gap:14px; }
.dashboard-brand-mark { width:68px; height:68px; border-radius:20px; box-shadow: var(--shadow); flex:0 0 auto; }
@media (max-width: 680px) {
  .site-brand-wordmark { display:none; }
  .dashboard-brand-mark { width:56px; height:56px; border-radius:16px; }
}
.site-nav { display: flex; gap: 4px; height: 100%; align-items: stretch; position: relative; z-index: 1201; }

/* Dropdown toggle button */
.nav-dropdown { position: relative; display: flex; align-items: stretch; z-index: 1202; }
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: rgba(255,255,255,.7);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.nav-dropdown-toggle:hover { color: #fff; }
.nav-dropdown-toggle.active { color: #fff; border-bottom-color: #fff; }
.site-nav-icon { width: 16px; height: 16px; margin-right: 4px; opacity: .8; }
.nav-caret { width: 10px; height: 6px; opacity: .5; margin-left: 2px; }
.nav-dropdown-toggle:hover .nav-caret { opacity: .8; }

/* Dropdown menu */
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 2500;
  padding: 4px 0;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition);
}
.nav-dropdown-menu a:hover { background: var(--bg-soft); text-decoration: none; }
.nav-dropdown-menu a.active { color: var(--blue); font-weight: 600; }
.dd-icon { width: 16px; height: 16px; flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; }
.dd-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* User preferences in header */
.user-prefs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.pref-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  height: 30px;
  min-width: 30px;
  transition: all var(--transition);
}
.pref-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.pref-icon { width: 16px; height: 16px; }
.font-size-ctrl {
  display: flex;
  align-items: center;
  gap: 2px;
}
.font-size-label {
  color: rgba(255,255,255,.6);
  font-size: 11px;
  min-width: 20px;
  text-align: center;
}

/* Theme icon visibility */
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

/* Dark theme overrides for header */
[data-theme="dark"] .site-header {
  background: #0B1120;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
[data-theme="dark"] .nav-dropdown-menu {
  background: #1E293B;
  border-color: #334155;
}
[data-theme="dark"] .nav-dropdown-menu a { color: #E2E8F0; }
[data-theme="dark"] .nav-dropdown-menu a:hover { background: #334155; }
[data-theme="dark"] .nav-dropdown-menu a.active { color: #60A5FA; }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Page Container --- */
.page { padding: 20px; max-width: 1600px; margin: 0 auto; }
.page-sm { max-width: 1100px; }

/* --- Page Title Bar --- */
.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  font-style: italic;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* --- Buttons --- */
.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-dark);
  background: var(--bg-soft);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  line-height: 1.4;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover,
.button:hover {
  background: var(--navy-light);
  border-color: var(--navy-light);
  color: #fff;
  text-decoration: none;
}
.btn:disabled,
.button:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-primary,
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover,
.button.primary:hover { background: #1D4ED8; border-color: #1D4ED8; }
.btn-danger,
.button.danger { color: var(--red); border-color: #FECACA; }
.btn-danger:hover,
.button.danger:hover { background: var(--red-light); color: var(--red); }
.btn-ghost {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-soft); }
.button.secondary {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
.button.secondary:hover {
  background: var(--bg-soft);
  border-color: var(--slate-light);
  color: var(--text);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px;
}
.icon-btn:hover { color: var(--text); }
.admin-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.admin-tool-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.admin-tool-link:hover {
  background: var(--bg);
  border-color: var(--blue);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.admin-tool-link-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.admin-tool-link-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* --- Cards --- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

/* --- Stats Pills --- */
.stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.pill strong, .pill b { color: var(--text); font-weight: 600; }
.pill-blue { border-color: var(--blue-light); background: var(--blue-light); color: var(--blue); }
.pill-green { border-color: var(--green-light); background: var(--green-light); color: var(--green); }
.pill-amber { border-color: var(--amber-light); background: var(--amber-light); color: var(--amber); }
.pill-red { border-color: var(--red-light); background: var(--red-light); color: var(--red); }

/* --- Inline Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.filter-field input,
.filter-field select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg);
  min-width: 0;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.filter-field-wide { flex: 1; min-width: 180px; }
.filter-field-date input { width: 130px; }
.filter-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-bottom: 1px;
}

/* --- Forms (modal/page forms) --- */
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.form-row { margin-top: 12px; }
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.35;
}
th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(37,99,235,.02); }
td { word-break: break-word; overflow-wrap: anywhere; }

/* Search results table */
.results-table th:nth-child(1), .results-table td:nth-child(1) { width: 130px; }
.results-table th:nth-child(2), .results-table td:nth-child(2) { width: 220px; }
.results-table th:nth-child(3), .results-table td:nth-child(3) { width: auto; }

/* ── Conversation: Chat-style layout ── */
.conv-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.conv-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
}
.conv-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.conv-part-name { font-weight: 500; }
.conv-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.conv-filter-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.conv-filter-input {
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  max-width: 200px;
}
.conv-bulk-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.conv-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* Chat stream */
.chat-stream {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.chat-date-divider {
  text-align: center;
  padding: 8px 0 5px;
  position: sticky;
  top: 52px;
  z-index: 5;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.date-label {
  display: inline-block;
  padding: 1px 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all var(--transition);
  cursor: pointer;
}
.chat-date-divider[data-date]:hover .date-label {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}

/* Date count badge */
.date-count-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 30px;
}
.date-count-badge.has-selections {
  color: var(--green);
}

/* Reviewed toggle button */
.date-reviewed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-dark);
  background: transparent;
  color: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  vertical-align: middle;
  flex-shrink: 0;
}
.date-reviewed-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}
.date-reviewed-btn.is-reviewed {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.chat-date-divider.day-reviewed .date-label {
  border-color: var(--green);
  color: var(--green);
}

/* Day-view modal messages */
.day-msg-list { padding: 8px 0; }
.day-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--border);
}
.day-msg:hover { background: var(--bg-soft); }
.chat-msg {
  display: grid;
  grid-template-columns: 24px 36px minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
  scroll-margin-top: 140px;
}
.chat-msg-target {
  position: relative;
  background: var(--blue-light);
  box-shadow: inset 3px 0 0 var(--blue);
}
.chat-msg-target-flash {
  animation: chatTargetPulse 1.8s ease-out 1;
}
@keyframes chatTargetPulse {
  0% { box-shadow: inset 3px 0 0 var(--blue), 0 0 0 0 rgba(37, 99, 235, 0.40); }
  70% { box-shadow: inset 3px 0 0 var(--blue), 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: inset 3px 0 0 var(--blue), 0 0 0 0 rgba(37, 99, 235, 0); }
}
.chat-msg:hover { background: var(--bg-soft); }
.chat-msg-selected { background: var(--blue-light); }
.chat-msg-selected:hover { background: var(--blue-light); }
.chat-msg-kw { border-left: 3px solid var(--blue); }
.chat-check {
  align-self: center;
  padding-top: 6px;
}
.chat-avatar {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
}
.chat-avatar-bubble {
  --sender-hue: 219;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: hsl(var(--sender-hue) 70% 24%);
  background: hsl(var(--sender-hue) 85% 92%);
  border: 1px solid hsl(var(--sender-hue) 55% 78%);
  flex-shrink: 0;
}
.chat-avatar-bubble.is-repeat {
  opacity: 0.5;
}
.chat-body {
  min-width: 0;
}
.chat-sender-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  min-height: 16px;
}
.chat-sender-row.is-repeat {
  display: none;
}
.chat-sender {
  font-weight: 600;
  font-size: 11px;
  color: var(--blue);
}
.chat-time,
.chat-time-only {
  display: none !important;
}
.chat-bubble-shell {
  display: flex;
  align-items: flex-start;
}
.chat-bubble {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 7px 10px;
}
.chat-bubble-shell.is-repeat .chat-bubble {
  border-top-left-radius: 8px;
}
.chat-kw-badge {
  font-size: 9px;
  padding: 0 4px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 3px;
  font-weight: 600;
}
.chat-text {
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-text:empty { display: none; }
.chat-attachments {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.chat-actions {
  min-width: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
  padding-top: 2px;
}
.chat-note-preview {
  display: none;
  max-width: 220px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.conv-header { display: none; } /* deprecated, kept for compat */
.conv-participants { display: none; }

/* Dark mode chat */
[data-theme="dark"] .chat-msg-selected { background: #1E3A5F; }
[data-theme="dark"] .chat-msg-target { background: #1E3A5F; box-shadow: inset 3px 0 0 #60A5FA; }
[data-theme="dark"] .conv-filter-input { background: #0F172A; color: #E2E8F0; border-color: #475569; }
[data-theme="dark"] .date-reviewed-btn { border-color: #475569; }
[data-theme="dark"] .date-reviewed-btn.is-reviewed { border-color: #4ADE80; background: #16A34A; }
[data-theme="dark"] .date-count-badge.has-selections { color: #4ADE80; }
[data-theme="dark"] .chat-bubble { background: rgba(255,255,255,0.04); border-color: #334155; }
[data-theme="dark"] .chat-avatar-bubble {
  color: hsl(var(--sender-hue) 85% 88%);
  background: hsl(var(--sender-hue) 40% 22%);
  border-color: hsl(var(--sender-hue) 45% 34%);
}
[data-theme="dark"] .chat-note-preview { background: rgba(255,255,255,0.04); border-color: #334155; }

/* Review checkbox */
.review-check {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* Sticky-note icon button */
.note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--slate-light);
  transition: all var(--transition);
  position: relative;
  font-size: 16px;
}
.note-btn:hover { background: var(--bg-warm); color: var(--amber); }
.note-btn.has-notes { color: var(--amber); }
.note-btn.has-notes::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 50%;
}

/* Note popover */
.note-popover {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 50;
  width: 300px;
  background: var(--bg);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px;
}
.note-popover.open { display: block; }
.note-popover-field { margin-bottom: 8px; }
.note-popover-field:last-child { margin-bottom: 0; }
.note-popover-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.note-popover-field input,
.note-popover-field textarea {
  font-size: 12px;
  padding: 6px 8px;
}
.note-popover-field textarea { resize: vertical; min-height: 60px; }
.note-save-state {
  font-size: 11px;
  color: var(--text-muted);
  min-height: 16px;
  margin-top: 4px;
}
.note-cell-wrap { position: relative; }

/* Message text in conversation */
.msg-text { line-height: 1.35; font-size: 12px; }
.msg-sender { font-weight: 600; font-size: 12px; }
.sender-actions {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  vertical-align: middle;
}
tr:hover .sender-actions { opacity: 1; }
.sender-actions .chip-link { font-size: 10px; padding: 0 4px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-time a { color: var(--text-muted); }
.msg-time a:hover { color: var(--blue); }

/* Keyword highlight */
.kw-match { background: var(--amber-light); border-radius: 2px; padding: 0 1px; }

/* --- Attachment links --- */
.att-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.att-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.att-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
  text-decoration: none;
}
.att-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Participants --- */
.participants-list { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.conv-cell-header { display: flex; align-items: center; gap: 4px; }
.conv-cell-header a { flex: 1; }
.participant-row { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.chip-link:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); text-decoration: none; }
.chip-danger:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-links { display: flex; gap: 4px; }
.pagination-links a,
.pagination-links span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}
.pagination-links a:hover { background: var(--bg-soft); border-color: var(--slate-light); }
.pagination-links .active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 2000;
  backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }

/* --- Collapsible (details) --- */
.collapsible summary { list-style: none; cursor: pointer; }
.collapsible summary::-webkit-details-marker { display: none; }
.details-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.details-badge { color: var(--text-muted); font-size: 12px; }
.details-body { margin-top: 12px; }

/* --- Checkbox Grid (quick exclude) --- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.check-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  background: var(--bg);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.check-pill:hover { background: var(--bg-soft); }
.check-pill input { width: auto; margin: 0; }

/* --- Two-column layout --- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Aliases --- */
.alias-form {
  display: grid;
  grid-template-columns: 140px 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}
.alias-row, .saved-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.alias-row:first-child, .saved-filter-row:first-child { border-top: none; }
.alias-row-actions { display: flex; gap: 6px; align-items: center; }

/* --- Import page --- */
.import-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 16px;
}
.import-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.import-row:first-child { border-top: none; }
.import-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.progress-wrap {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
  height: 14px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), #60A5FA);
  transition: width 300ms ease;
}

/* --- Message Detail page --- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.meta-grid strong { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  font-family: var(--font);
}
.context-list { display: grid; gap: 6px; }
.context-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
}
.context-target { border-color: var(--blue); background: var(--blue-light); }
.context-meta { font-size: 11px; margin-bottom: 4px; color: var(--text-muted); }

/* --- Flash messages --- */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  border-left: 3px solid var(--blue);
  background: var(--blue-light);
}
.flash-success { border-left-color: var(--green); background: var(--green-light); }
.flash-error { border-left-color: var(--red); background: var(--red-light); }

/* --- Context menu --- */
.ctx-menu {
  display: none;
  position: fixed;
  z-index: 3000;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  font-size: 12px;
}
.ctx-menu.open { display: block; }
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 12px;
}
.ctx-menu-item:hover { background: var(--bg-soft); }
.ctx-menu-sep { border-top: 1px solid var(--border); margin: 4px 0; }
.ctx-menu-label { padding: 4px 12px; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ctx-menu-detail { padding: 4px 12px; font-size: 10px; color: var(--text-muted); word-break: break-all; max-width: 350px; }

/* --- Utilities --- */
.muted { color: var(--text-muted); font-size: 12px; }
.small-muted { color: var(--text-muted); font-size: 11px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 12px; }
.gap-sm { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.row-hidden { display: none !important; }
.path-line { overflow-wrap: anywhere; font-size: 11px; color: var(--text-muted); }
.inline-form { display: inline; }
.stack > * + * { margin-top: 10px; }

@media (min-width: 1280px) {
  .chat-actions {
    min-width: 120px;
  }
  .chat-note-preview {
    display: -webkit-box;
  }
}

@media (min-width: 1550px) {
  .chat-stream {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    align-items: start;
  }
  .chat-date-divider {
    grid-column: 1 / -1;
    position: static;
    padding: 0;
    margin: 4px 0 0;
  }
  .chat-msg {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 10px;
    background: var(--bg);
  }
  .chat-msg:hover { background: var(--bg-soft); }
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .site-header { padding: 0 12px; }
  .site-brand { margin-right: 16px; font-size: 17px; }
  .site-nav a { padding: 0 10px; font-size: 12px; }
  .page { padding: 12px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-field-date input { width: 100%; }
  .two-col, .import-grid, .alias-form, .meta-grid { grid-template-columns: 1fr; }
  .note-popover { width: 260px; right: -40px; }
  .chat-msg {
    grid-template-columns: 24px 30px minmax(0, 1fr) 32px;
    column-gap: 6px;
    padding: 5px 8px;
  }
  .chat-avatar-bubble {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }
  .chat-bubble {
    padding: 6px 8px;
    border-radius: 12px;
  }
}

/* ========================================================================
   Legal Case Builder — Component Styles
   ======================================================================== */

/* Nav divider */
.nav-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,.2);
  margin: 0 8px;
  align-self: center;
}

/* Timeline list */
.timeline-list { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 90px;
  padding-top: 2px;
}
.timeline-content { flex: 1; }

/* Pill variants */
.pill-sm { font-size: 11px; padding: 1px 7px; }
.pill-amber { background: var(--amber-light); color: var(--amber); border-color: var(--amber); }
.pill-red { background: var(--red-light); color: var(--red); border-color: var(--red); }
.pill-green { background: var(--green-light); color: var(--green); border-color: var(--green); }

/* Field label + input for legal forms */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 3px;
}
.field-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.field-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
textarea.field-input {
  resize: vertical;
  min-height: 60px;
}
select.field-input {
  cursor: pointer;
}

/* Data tables for legal sections */
.data-table {
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--bg-soft);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:hover {
  background: var(--bg-soft);
}

/* Modal improvements */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  width: 90%;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========================================================================
   Dark Theme — Element Overrides
   ======================================================================== */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="file"],
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .field-input {
  background: #0F172A;
  color: #E2E8F0;
  border-color: #475569;
}
[data-theme="dark"] .field-input:focus {
  border-color: #60A5FA;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .15);
}
[data-theme="dark"] .btn {
  background: #1E293B;
  color: #E2E8F0;
  border-color: #475569;
}
[data-theme="dark"] .btn:hover { background: #334155; }
[data-theme="dark"] .btn-primary { background: #2563EB; border-color: #2563EB; color: #fff; }
[data-theme="dark"] .btn-primary:hover { background: #1D4ED8; }
[data-theme="dark"] .btn-danger { color: #F87171; border-color: #7F1D1D; }
[data-theme="dark"] .btn-danger:hover { background: #450A0A; }
[data-theme="dark"] .flash-success { background: #052E16; color: #4ADE80; border-color: #166534; }
[data-theme="dark"] .flash-error { background: #450A0A; color: #F87171; border-color: #7F1D1D; }
[data-theme="dark"] .modal { background: #1E293B; }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.7); }
[data-theme="dark"] option { background: #1E293B; color: #E2E8F0; }

/* =========================================================================
   LegalPrep v2 — Phase 1 CSS Additions
   Append this to the END of app.css
   ========================================================================= */

/* --- Modal content (used by admin/client modals) --- */
.modal-content {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-content .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-content .modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* --- Nav link (non-dropdown top-level link) --- */
.nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: var(--font-size-base);
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.active { color: var(--text); font-weight: 600; }

/* --- User menu in header --- */
.user-menu-toggle {
  font-size: calc(var(--font-size-base) - 1px);
}
.user-menu-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Logout button in dropdown --- */
.dd-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  color: var(--red, #dc2626);
  text-align: left;
  font-family: inherit;
}
.dd-logout-btn:hover {
  background: var(--surface-hover);
}

/* --- Pill variants --- */
.pill-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
a.pill { text-decoration: none; }
a.pill:hover { opacity: 0.85; }

/* --- Detail table (key/value pairs) --- */
.detail-table {
  width: 100%;
  border-collapse: collapse;
}
.detail-table td {
  padding: 5px 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light, var(--border));
  font-size: calc(var(--font-size-base) - 1px);
}
.detail-table td:first-child {
  width: 140px;
  white-space: nowrap;
}
.detail-table tr:last-child td {
  border-bottom: none;
}

/* --- Data table enhancements --- */
.data-table {
  border-collapse: collapse;
  font-size: calc(var(--font-size-base) - 1px);
}
.data-table th {
  text-align: left;
  padding: 8px;
  font-weight: 600;
  font-size: calc(var(--font-size-base) - 2px);
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.data-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-light, var(--border));
  vertical-align: middle;
}
.data-table tbody tr:hover {
  background: var(--surface-hover, rgba(0,0,0,.02));
}

/* --- Button danger variant --- */
.btn-danger {
  background: var(--red, #dc2626);
  color: #fff;
  border-color: var(--red, #dc2626);
}
.btn-danger:hover {
  opacity: 0.9;
}

/* --- Dark mode additions --- */
[data-theme="dark"] .modal-content { background: var(--bg, #1a1a2e); }
[data-theme="dark"] .dd-logout-btn { color: #f87171; }
[data-theme="dark"] .pill-active { background: var(--accent); color: #fff; }


/* --- Calendar --- */
.calendar-toolbar {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:16px;
}
.calendar-layout {
  display:grid;
  grid-template-columns:minmax(320px, 380px) minmax(0, 1fr);
  gap:16px;
  align-items:start;
}
.calendar-grid {
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  table-layout:fixed;
}
.calendar-grid th, .calendar-grid td {
  border:1px solid var(--border);
  vertical-align:top;
  background:var(--bg);
}
.calendar-grid th {
  padding:8px;
  background:var(--bg-soft);
  text-align:left;
  font-weight:600;
}
.calendar-grid td {
  height:128px;
  padding:8px;
}
.calendar-day-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
  gap:8px;
}
.calendar-day-num { font-weight:700; }
.calendar-day-muted { opacity:.5; }
.calendar-day-today { outline:2px solid var(--blue); outline-offset:-2px; }
.calendar-event-chip {
  display:block;
  padding:5px 7px;
  border-radius:6px;
  margin-bottom:6px;
  background:var(--bg-soft);
  border:1px solid var(--border);
  color:var(--text);
  text-decoration:none;
}
.calendar-event-chip:hover { text-decoration:none; border-color:var(--blue); }
.calendar-event-chip.is-deadline { border-left:4px solid var(--amber); }
.calendar-event-chip.is-hearing { border-left:4px solid var(--red); }
.calendar-event-chip.is-meeting { border-left:4px solid var(--blue); }
.calendar-event-chip.is-personal { border-left:4px solid var(--green); }
.calendar-chip-time { display:block; font-size:12px; color:var(--text-muted); }
.calendar-chip-title { display:block; font-weight:600; }
.calendar-side-list { display:flex; flex-direction:column; gap:10px; }
.calendar-side-item { padding:10px 12px; border:1px solid var(--border); border-radius:8px; background:var(--bg); }
.calendar-summary { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:12px; margin-bottom:16px; }
.calendar-summary .card-title { margin-bottom:4px; }
.calendar-inline-actions { display:flex; gap:8px; flex-wrap:wrap; }
@media (max-width: 1100px) {
  .calendar-layout { grid-template-columns:1fr; }
  .calendar-summary { grid-template-columns:repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .calendar-grid td { height:auto; min-height:96px; }
  .calendar-summary { grid-template-columns:1fr; }
}


/* --- Compact intl-tel-input hotfix --- */
.iti {
  width: 100%;
}
.iti input[data-phone-input],
.iti input[type="tel"],
.iti input[type="text"] {
  width: 100% !important;
  min-width: 0;
  padding-left: 10px !important;
}
.iti .iti__trigger {
  min-width: 0;
}
.iti .iti__dropdown {
  background: var(--surface);
}
.form-group .iti,
.field .iti,
.card .iti {
  display: grid;
}



.dashboard-grid { display:grid; gap:16px; }
.dashboard-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-sm { display:flex; flex-direction:column; gap:10px; }
.list-line { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; border-bottom:1px solid var(--border); padding-bottom:8px; }
.dashboard-bar-label { display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:12px; margin-bottom:4px; }
.dashboard-bar-track { height:10px; border-radius:999px; background:var(--surface-muted); overflow:hidden; }
.dashboard-bar-fill { height:100%; border-radius:999px; background:var(--accent); }
.dashboard-mini-stats { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:10px; }
.mini-stat { border:1px solid var(--border); border-radius:12px; padding:12px; background:var(--surface); }
.mini-stat-label { font-size:12px; color:var(--muted); margin-bottom:6px; }
.mini-stat-value { font-size:22px; font-weight:700; line-height:1.1; }
@media (max-width: 980px) { .dashboard-grid-two { grid-template-columns:1fr; } .dashboard-mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dashboard-mini-stats { grid-template-columns:1fr; } .list-line { flex-direction:column; } }

/* ── Grid layout ── */
.grid { display:grid; gap:16px; }
.grid-2 { grid-template-columns:1fr 1fr; }
@media (max-width: 980px) { .grid-2 { grid-template-columns:1fr; } }

/* ── Surface / subtle bg variables ── */
:root, [data-theme="light"] {
  --surface: #FFFFFF;
  --surface-muted: #F1F5F9;
  --surface-hover: rgba(0,0,0,.03);
  --bg-subtle: #F8FAFC;
}
[data-theme="dark"] {
  --surface: #1E293B;
  --surface-muted: #334155;
  --surface-hover: rgba(255,255,255,.05);
  --bg-subtle: #0F172A;
}

/* ── Filing Checklist ── */
.filing-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px;
  background: var(--surface);
  transition: background var(--transition), border-color var(--transition);
}
.checklist-item.checklist-done {
  background: var(--green-light);
  border-color: var(--green);
}
.checklist-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.checklist-label {
  font-weight: 500;
}
.checklist-detail {
  font-size: 11px;
  margin-left: 4px;
}

/* ── Nav overdue badge ── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--red);
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}
.nav-badge-amber {
  background: var(--amber);
}

/* ── Filing status filter bar ── */
.filing-filter-bar .btn-xs.active,
.filing-filter-bar .btn-xs.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ── Version content preview ── */
.version-content-preview pre {
  tab-size: 4;
  word-wrap: break-word;
}

/* --- Desktop-first workspace modals and stat/report cards --- */
.modal-overlay {
  padding: 24px;
  align-items: center;
  justify-content: center;
}
.modal-workspace,
.modal-content {
  width: min(1600px, calc(100vw - 48px));
  max-width: min(1600px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.modal-workspace > form,
.modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.modal-workspace .modal-header,
.modal-content .modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
}
.modal-workspace .modal-body,
.modal-content .modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 20px 24px;
}
.modal-workspace .modal-footer,
.modal-content .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--bg);
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px 16px;
  align-items: start;
}
.modal-grid > div {
  min-width: 0;
}
.modal-grid .field-input,
.modal-grid input,
.modal-grid select,
.modal-grid textarea {
  width: 100%;
}
.modal-span-12 { grid-column: span 12; }
.modal-span-9 { grid-column: span 9; }
.modal-span-8 { grid-column: span 8; }
.modal-span-6 { grid-column: span 6; }
.modal-span-4 { grid-column: span 4; }
.modal-span-3 { grid-column: span 3; }
.modal-span-2 { grid-column: span 2; }
.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  text-decoration: none;
  text-align: center;
  padding: 18px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.stat-card:hover {
  text-decoration: none;
  border-color: var(--blue);
}
.stat-card-value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 800;
  color: var(--blue);
}
.stat-card-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.report-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.report-panel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.report-panel-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.report-panel-row:last-child {
  border-bottom: none;
}
.report-panel-row strong,
.report-panel-row .report-primary {
  color: var(--text);
  font-weight: 600;
}
.report-panel-row .report-secondary {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 2px;
}
@media (max-width: 991px) {
  .modal-overlay {
    padding: 12px;
  }
  .modal-workspace,
  .modal-content {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }
  .modal-span-9,
  .modal-span-8,
  .modal-span-6,
  .modal-span-4,
  .modal-span-3,
  .modal-span-2 {
    grid-column: span 12;
  }
  .report-panels {
    grid-template-columns: 1fr;
  }
}
[data-theme="dark"] .modal-workspace .modal-header,
[data-theme="dark"] .modal-workspace .modal-footer,
[data-theme="dark"] .modal-content .modal-header,
[data-theme="dark"] .modal-content .modal-footer {
  background: #1E293B;
}


/* --- Leaflet controls should stay below header menus --- */
.leaflet-container,
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control {
  z-index: 10 !important;
}
.header-right {
  position: relative;
  z-index: 2501;
}
