@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* BLK Partners shared design tokens — navy/slate palette (matches the
     Matter Pricing Tool's straightforward color display), now the standard
     theme for the whole app. Named roles, for reference:
       navy #0f2a3d, navy-2 #173e57, slate #5b7185, line #d7dfe4,
       bg #f6f8f9, panel #ffffff, good #1e7d4a, bad #b3261e.
     amber (#f2c14e) is intentionally not wired in anywhere — reserved for a
     formula/guide-style callout this app doesn't have, same as the source
     palette's own rule. */
  --primary-color: #173e57;       /* navy-2 — links, computed values, primary actions */
  --primary-color-dark: #0f2a3d;  /* navy — headers, hover state */
  --primary-color-light: #d7dfe4; /* line — light tint fills */
  --secondary-color: #0f2a3d;     /* navy */
  --background-color: #f6f8f9;    /* bg */
  --gray-color: #5b7185;          /* slate */
  --gray-color-light: #f6f8f9;    /* bg */
  --danger-color: #b3261e;        /* bad */
  --success-color: #1e7d4a;       /* good */

  /* Legacy names used throughout this file — aliased to the tokens above so
     the whole app repaints from one place instead of a full find/replace. */
  --navy: var(--secondary-color);
  --navy-dark: var(--secondary-color);
  --blue: var(--primary-color-dark);
  --blue-light: var(--primary-color-light);
  --accent: var(--primary-color);
  --accent-dark: var(--primary-color-dark);
  --green: var(--success-color);
  --green-bg: #e5f3ea;
  --red: var(--danger-color);
  --red-bg: #fbeaea;
  --gray-50: var(--gray-color-light);
  --gray-100: #eef2f4;
  --gray-200: #d7dfe4;
  --gray-400: #7c8aa0;
  --gray-600: var(--gray-color);
  --gray-800: #101828;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background-color);
  color: var(--gray-800);
  font-size: 11px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--navy);
  background-image: linear-gradient(135deg, var(--navy) 0%, var(--primary-color-dark) 100%);
  color: #fff;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  /* Orange accent stripe, matching the Matter Pricing Tool's header - kept
     as a literal color rather than a new token, since --accent is still
     the navy used for links/computed values elsewhere in this file. */
  border-bottom: 3px solid #cc6633;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  height: 32px;
  width: 32px;
  background: #fff;
  border-radius: 50%;
  padding: 3px;
  object-fit: contain;
  box-shadow: 0 0 0 2px #cc6633, 0 1px 4px rgba(0, 0, 0, 0.25);
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-on-dark {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: background 0.15s, border-color 0.15s;
}

.btn-on-dark:hover { background: rgba(255, 255, 255, 0.12); border-color: #fff; }
.btn-on-dark:disabled { opacity: 0.4; cursor: default; }
.btn-on-dark:disabled:hover { background: transparent; border-color: rgba(255, 255, 255, 0.35); }

/* Header "Conflict Check" link, disabled for a read-only deep link from the
   Matter Pricing Tool (see app.js's readOnlyMode) - a plain <a> ignores the
   disabled attribute, so this is applied instead alongside removing href. */
.nav-link-disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.nav-link-disabled:hover { background: transparent; border-color: rgba(255, 255, 255, 0.35); }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: #fff;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.user-badge #user-badge-name {
  font-weight: 700;
}

.user-badge .btn-secondary {
  padding: 5px 10px;
  font-size: 10.5px;
}

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--gray-600);
}

.content {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

/* Large screens (>1500px) — the fixed 1080px container leaves most of a big
   monitor empty; widen it so tables/results actually use the space. */
@media (min-width: 1500px) {
  .content { max-width: 1440px; }
}

.search-card,
.result-header,
.record-panel,
.status-panel,
.categories-panel,
.summary-panel,
.results-panel,
.history-panel,
.send-report-panel,
.approvals-panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
}

.search-card { margin-bottom: 14px; }

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 180px;
}

.field-grow { flex: 1 1 320px; }

.field label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field input {
  padding: 7px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 12px;
  background-color: var(--gray-50);
  transition: border-color 0.15s, background-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #fff;
}

/* Leading icons on inputs — matches the reference design's icon-prefixed
   fields. Self-contained inline SVGs (no external icon font/CDN request). */
.icon-person, .icon-email, .icon-phone, .icon-company, .icon-tag {
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px 14px;
  padding-left: 32px !important;
}

.icon-person {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E") !important;
}

.icon-email {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-10 5L2 7'/%3E%3C/svg%3E") !important;
}

.icon-phone {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z'/%3E%3C/svg%3E") !important;
}

.icon-company {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='7' width='20' height='14' rx='2'/%3E%3Cpath d='M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16'/%3E%3C/svg%3E") !important;
}

.icon-tag {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41 11 3.83A2 2 0 0 0 9.61 3H4a1 1 0 0 0-1 1v5.61c0 .53.21 1.04.59 1.42l9.58 9.58a2 2 0 0 0 2.82 0l4.6-4.6a2 2 0 0 0 0-2.82Z'/%3E%3Ccircle cx='7.5' cy='7.5' r='1.2'/%3E%3C/svg%3E") !important;
}

.field-btn { min-width: 0; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray-800);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  min-width: 15px;
  border: 1.5px solid var(--gray-400);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  margin: 0;
  transition: background 0.15s, border-color 0.15s;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-with-variants {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 7px 9px 9px;
}

.field-with-variants input { background-color: #fff; }


.variants {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.variant-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.variant-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 11px;
  background: var(--gray-50);
}

.variant-row input:focus { outline: none; border-color: var(--accent); background: #fff; }

.remove-variation-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.remove-variation-btn:hover { color: var(--red); }

.add-variation-btn, .add-related-party-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 0;
  margin-top: 3px;
  text-align: left;
}

.add-variation-btn:hover, .add-related-party-btn:hover { text-decoration: underline; }

.suggest-variations-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 0;
  margin-top: 3px;
  text-align: left;
}
.suggest-variations-btn:hover { text-decoration: underline; }
.suggest-variations-btn:disabled { color: var(--gray-400); cursor: default; text-decoration: none; }

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px dashed #c3d0d8;
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
  font-size: 11px;
}
.suggestion-chip .suggestion-add {
  background: none;
  border: none;
  color: var(--navy);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.suggestion-chip .suggestion-add:hover { text-decoration: underline; color: var(--accent); }
.suggestion-chip .suggestion-discard {
  background: none;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
}
.suggestion-chip .suggestion-discard:hover { color: var(--red); }

.related-parties-section {
  border-top: 1px solid var(--gray-100);
  margin-top: 10px;
  padding-top: 10px;
}

.related-parties-section > label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field-hint {
  margin: 3px 0 7px;
  font-size: 10px;
  color: var(--gray-400);
}

.requested-by-to-display {
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background-color: var(--gray-50);
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
}

.related-party-group {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 7px 9px;
  margin-bottom: 7px;
}

.related-party-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.related-party-group .variants { margin-top: 6px; margin-left: 0; }
.related-party-group .add-variation-btn { margin-top: 4px; }

.related-party-row input[type="text"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 11px;
  background-color: #fff;
}

.related-party-row input[type="text"]:focus { outline: none; border-color: var(--accent); background-color: #fff; }

.related-party-row select {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 11px;
  background: #fff;
}

.category-checkboxes {
  display: flex;
  gap: 12px;
  padding: 6px 0;
}

.search-options-row {
  border-top: 1px solid var(--gray-100);
  margin-top: 10px;
  padding-top: 10px;
}

.segmented {
  display: flex;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
}

.segmented-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 11px;
  cursor: pointer;
  background: var(--gray-50);
  transition: background 0.15s, color 0.15s;
}

.segmented-option:not(:last-child) { border-right: 1px solid var(--gray-200); }

.segmented-option input[type="radio"] { accent-color: var(--accent); }

.segmented-option:has(input:checked) {
  background: var(--blue-light);
  color: var(--accent);
  font-weight: 600;
}

button#search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

button#search-btn:hover { background: var(--accent-dark); }
button#search-btn:disabled { background: var(--gray-400); cursor: default; }

.empty-state, .loading-state, .error-state {
  text-align: center;
  color: var(--gray-600);
  padding: 30px 16px;
  font-size: 11px;
}

.error-state {
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #f0c9c6;
  border-radius: var(--radius);
}

.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 10px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.result { display: flex; flex-direction: column; gap: 12px; }

.result-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-block;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.result-title-row h1 {
  font-size: 15px;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
}

.status-badge.ok { background: var(--green-bg); color: var(--green); }
.status-badge.warn { background: var(--gray-100); color: var(--gray-800); }
.status-badge.danger { background: var(--red-bg); color: var(--red); }

.banner {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 11px;
}

.banner.ok { background: var(--green-bg); color: var(--green); border: 1px solid #bfe3c8; }
.banner.warn { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.banner.danger { background: var(--red-bg); color: var(--red); border: 1px solid #f0c9c6; }

.clearance-banner {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 11px;
  background: var(--blue-light);
  border: 1px solid #c3d0d8;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#send-clearance-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
}

#send-clearance-btn:hover { background: var(--accent-dark); }
#send-clearance-btn:disabled { background: var(--gray-400); cursor: default; }

#send-email-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: background 0.15s;
}

#send-email-btn:hover { background: var(--accent-dark); }
#send-email-btn:disabled { background: var(--gray-400); cursor: not-allowed; }

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 16px;
}

.record-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.record-field .label {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.record-field .value {
  font-size: 12px;
  color: var(--gray-800);
}

.record-field .value.strong { font-weight: 700; color: var(--navy); }
.mono, .record-field .value.mono { font-family: "Courier New", monospace; font-weight: 700; color: var(--blue); }

.pill {
  display: inline-block;
  width: fit-content;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.pill.yes-good, .pill.no-good { background: var(--green-bg); color: var(--green); }
.pill.yes-bad, .pill.no-bad { background: var(--red-bg); color: var(--red); }

.status-panel h2, .categories-panel h2, .summary-panel h2, .send-report-panel h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 0 0 8px;
}

.status-top-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.status-select-field { min-width: 220px; }

.comments-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--gray-50);
  font-family: inherit;
  resize: vertical;
  min-height: 56px;
}

.comments-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.status-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

#save-status-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: background 0.15s;
}

#save-status-btn:hover { background: var(--accent); }

.save-confirmation {
  margin: 0;
  font-size: 10px;
  color: var(--green);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.category-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}

.category-tile {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
  background: var(--gray-50);
}

.category-tile.live { background: var(--blue-light); border-color: #c3d0d8; }
.category-tile.has-matches { background: var(--red-bg); border-color: #f0c9c6; }

.category-tile .count {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.category-tile.has-matches .count { color: var(--red); }

.category-tile .cat-name {
  display: block;
  font-size: 9.5px;
  color: var(--gray-600);
  margin-top: 2px;
}

.results-panel h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 0 0 8px;
}

.table-wrap { overflow-x: auto; }

.category-section {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.category-section:last-child { margin-bottom: 0; }

.category-section summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--gray-50);
  user-select: none;
}

.category-section summary::-webkit-details-marker { display: none; }

.category-section summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 10px;
  transition: transform 0.15s ease;
}

.category-section[open] summary::before { transform: rotate(90deg); }

.category-section .cat-title {
  font-weight: 700;
  color: var(--navy);
  font-size: 11px;
}

.category-section .cat-badge {
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
}

table.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

table.results-table thead th {
  text-align: left;
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
  padding: 6px 9px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table.results-table tbody td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

table.results-table tbody tr:hover { background: var(--gray-50); }

table.approvals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

table.approvals-table thead th {
  text-align: left;
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
  padding: 6px 9px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table.approvals-table tbody td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

.approval-status-pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.approval-status-pill.pending { background: var(--gray-100); color: var(--gray-800); }
.approval-status-pill.approved { background: var(--green-bg); color: var(--green); }
.approval-status-pill.not-approved { background: var(--red-bg); color: var(--red); }

.branch-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-800);
}

.branch-tag.lebanon { background: #eaf3ea; color: #276b32; }
.branch-tag.riyadh { background: #f2ecdc; color: #8a6d1e; }
.branch-tag.dubai { background: #eeeeee; color: #555555; }

/* A hit sharing only one word of the searched name (e.g. "Marsh Insurance
   Brokers" for "Marsh Management") - a possible link for the reviewer. */
.partial-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 4px;
  background: #fff3e0;
  color: #9a5b00;
}

.result-name {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 3px;
}

/* Plain background only - no padding/border-radius/bold. Those made the
   highlighted phrase look like its own boxed-off block sitting inside the
   sentence (padding visibly pushes the surrounding words apart), which was
   especially disruptive inside long free text like an activity note. Just
   the background lets it read as one continuous sentence.
   white-space: nowrap keeps a multi-word match ("Bureau Veritas") together
   as one unit - without it, the browser can wrap a line right in the
   middle of the highlighted phrase itself (e.g. "Bureau" at the end of one
   line, "Veritas" starting the next), same as it would for any other text.
   If there isn't room, the whole highlighted phrase now moves to the next
   line together instead of splitting mid-match. */
.hit-mark {
  background: var(--primary-color-light);
  color: var(--secondary-color);
  white-space: nowrap;
}

/* Gray, not blue, for a related/adverse party name that is itself a hit on
   the search terms - blue stays reserved for the primary result's own
   .hit-mark highlight elsewhere on the row, so this reads as a distinct,
   secondary kind of match. A neutral gray, not --gray-200 (#d7dfe4), which
   is the same color as --primary-color-light used by .hit-mark itself and
   would read as the same blue, not a different color. */
.hit-mark-secondary {
  background: #dcdcdc;
  color: var(--secondary-color);
  white-space: nowrap;
}

.result-sub {
  font-size: 9.5px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
}

.matter-block {
  padding: 5px 0;
}

.note-toggle {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.note-toggle:hover { text-decoration: underline; }

.matter-block:not(:last-child) {
  border-bottom: 1px dashed var(--gray-200);
  margin-bottom: 5px;
}

.matter-title {
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
  margin-bottom: 2px;
}

.matter-meta {
  font-size: 9.5px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* Same look as .matter-meta but NOT display:flex - .matter-meta is meant for
   short label/value pairs like "Client: X", where flex+gap keeps them neatly
   inline. Long free text (e.g. an activity note) mixed with inline
   highlight <span>s breaks badly under flex: the browser splits the text
   and spans into separate anonymous flex items, and gap then spreads those
   fragments apart with huge gaps instead of letting them wrap as one normal
   paragraph. Plain block display lets it wrap like ordinary text. */
.matter-note {
  font-size: 9.5px;
  color: var(--gray-600);
  margin-top: 2px;
  line-height: 1.4;
}

.status-cell { min-width: 120px; }

.row-status-pill {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: var(--gray-50);
  color: var(--gray-800);
}

.row-status-pill.review-required { background: var(--gray-100); color: var(--gray-600); }
.row-status-pill.review-conflict { background: var(--red-bg); color: var(--red); border-color: #f0c9c6; }
.row-status-pill.review-no-conflict { background: var(--green-bg); color: var(--green); border-color: #bfe3c8; }

.no-results {
  text-align: center;
  color: var(--gray-400);
  padding: 16px 0 6px;
}

.history-panel { margin-bottom: 14px; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#history-search {
  width: 200px;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 11px;
  background-color: var(--gray-50);
  font-family: inherit;
}

#history-search:focus {
  outline: none;
  border-color: var(--accent);
  background-color: #fff;
}

.history-header h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 0;
}

table#history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

table#history-table thead th {
  text-align: left;
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table#history-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}

table#history-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

table#history-table tbody tr:nth-child(even) { background: var(--gray-50); }
table#history-table tbody tr:hover { background: var(--blue-light); }

.history-status-pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.history-status-pill.warn { background: var(--gray-100); color: var(--gray-800); }
.history-status-pill.danger { background: var(--red-bg); color: var(--red); }
.history-status-pill.ok { background: var(--green-bg); color: var(--green); }
.history-status-pill.info { background: var(--blue-light); color: var(--blue); }

.history-intake-btn { margin-left: 6px; padding: 3px 8px; font-size: 9px; vertical-align: middle; }

.app-footer {
  text-align: center;
  font-size: 10px;
  color: var(--gray-400);
  padding: 10px;
  border-top: 1px solid var(--gray-200);
}

.recipient-input-wrap { position: relative; }

.recipient-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
}

.recipient-option {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}

.recipient-option:last-child { border-bottom: none; }
.recipient-option:hover { background: var(--blue-light); }

.recipient-option .r-name { font-weight: 700; font-size: 11px; color: var(--navy); }
.recipient-option .r-detail { font-size: 9.5px; color: var(--gray-600); }

.recipient-option.empty {
  cursor: default;
  color: var(--gray-400);
  font-size: 10px;
}
.recipient-option.empty:hover { background: none; }

.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.recipient-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--blue-light);
  border: 1px solid #c3d0d8;
  border-radius: 999px;
  padding: 3px 5px 3px 10px;
  font-size: 10px;
  color: var(--navy);
}

.recipient-chip button {
  background: none;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 4px;
}

.recipient-chip button:hover { color: var(--red); }

/* ---------- Responsive ---------- */

/* Tablet / narrow desktop — most layout already wraps via flexbox at this
   width; this mainly tightens spacing so nothing feels cramped. */
@media (max-width: 900px) {
  .content { padding: 12px 12px 28px; }
  .field { min-width: 150px; }
}

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 12px; }

  .app-header { padding: 10px 14px; gap: 10px; }
  .brand-name { font-size: 14px; }
  .header-right { width: 100%; gap: 8px; }
  .header-right > * { flex: 1 1 auto; text-align: center; }
  .user-badge { border-left: none; padding-left: 0; flex-basis: 100%; justify-content: center; }

  .content { padding: 10px 10px 24px; }

  .search-card,
  .result-header,
  .record-panel,
  .status-panel,
  .categories-panel,
  .summary-panel,
  .results-panel,
  .history-panel,
  .send-report-panel,
  .approvals-panel {
    padding: 10px 12px;
  }

  .field { min-width: 0; width: 100%; }
  .field-row { gap: 8px; }
  .field-btn, button#search-btn { width: 100%; }

  .related-party-row { flex-wrap: wrap; }
  .related-party-row select { width: 100%; }

  .segmented { width: 100%; }
  .segmented-option { flex: 1; justify-content: center; }

  .category-checkboxes { flex-wrap: wrap; gap: 8px 14px; }

  .result-title-row { flex-wrap: wrap; }
  .header-actions { width: 100%; }
  .header-actions .btn-secondary { flex: 1 1 auto; text-align: center; }

  .record-grid { grid-template-columns: 1fr 1fr; }

  #history-search { width: 100%; }
  .history-header-actions { width: 100%; }
  .history-header-actions #close-history-btn { flex-shrink: 0; }

  .status-top-row { flex-direction: column; align-items: stretch; }
  .status-select-field { min-width: 0; }

  .clearance-banner { flex-direction: column; align-items: stretch; text-align: center; }
}

@media (max-width: 400px) {
  .record-grid { grid-template-columns: 1fr; }
}

/* Former inline style="" attributes on conflict-check.html - moved here so
   style-src can drop 'unsafe-inline' (CSP blocks inline style
   attributes the same as inline <style> blocks and JS-set styles). */
#history-pager { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--gray-600); }
.optional-label { font-weight: 400; color: var(--gray-600); }
.variant-actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-4 { margin-top: 4px; }

/* Former inline .style.x assignments in js/app.js - moved here so
   style-src can drop 'unsafe-inline' (CSP blocks direct CSSOM style
   mutation the same as inline style="" attributes and <style> blocks). */
.status-error { color: var(--red); }


/* ---------- Results summary (one row per distinct name) ----------
   Shown above the detailed Results; built by renderResultsSummary in
   app.js. Colors from the BLK theme (see theme-blk.css). */
.summary-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.summary-table th {
  text-align: left; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px;
  color: #6e6e6e; background: #eeeeee; padding: 6px 8px; border-bottom: 1px solid #d9d9d9;
}
.summary-table td { padding: 7px 8px; border-bottom: 1px solid #eeeeee; vertical-align: top; color: #1c1c1c; }
.summary-table col.col-name { width: 27%; }
.summary-table col.col-hit { width: 15%; }
.summary-table col.col-match { width: 14%; }
.summary-table col.col-found { width: 26%; }
.summary-table col.col-client { width: 18%; }
.summary-hit { font-weight: 700; color: #a84f27; word-break: break-word; }
.summary-name {
  background: none; border: none; padding: 0; font: inherit; font-weight: 700; color: #1c1c1c;
  text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: #d9d9d9;
  text-underline-offset: 3px;
}
.summary-name:hover { color: #cc6633; text-decoration-color: #cc6633; }
.match-tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }
.match-tag.same { background: #e6f4ea; color: #2e7d5b; }
.match-tag.contains { background: #eeeeee; color: #1c1c1c; }
.match-tag.partial { background: #fff3e0; color: #9a5b00; }
.summary-muted { color: #6e6e6e; }
.summary-table tr.summary-group td {
  background: #f5f5f5; color: #1c1c1c; font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .3px; padding: 5px 8px;
}
.summary-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 11px; color: #6e6e6e; }
/* Brief highlight on the detailed rows a summary name jumps to. */
tr.summary-target > td { animation: summary-flash 1.6s ease-out; }
@keyframes summary-flash { 0% { background: #fbeee6; } 100% { background: transparent; } }

/* "Back to summary" floating button (results page). */
.back-to-summary {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  background: #1c1c1c; color: #fff; border: none; border-radius: 4px;
  padding: 9px 14px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.back-to-summary:hover { background: #cc6633; }
