:root {
  --color-navy: #1f3864;
  --color-navy-mid: #2d4a80;
  --color-navy-deep: #1a2d4d;
  --color-accent: #2f6fdd;
  --color-bg: #f4f6f9;
  --color-surface: #fff;
  --color-border: #dde4ec;
  --color-border-input: #c6d0dc;
  --color-text: #1c2733;
  --color-muted: #6b7a8c;
  --color-muted-2: #4a5a6e;
  --color-danger: #c0392b;
  --color-danger-strong: #b3261e;
  --color-ok: #1e7e34;
  --color-warn: #9a6700;
  --color-warn-bg: #fffdf5;
  --color-warn-border: #e0c48a;
  --color-soft: #e8eef6;
  --color-header-muted: #c8d4ea;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-pill: 999px;
  --shadow-modal: 0 12px 40px rgba(0, 0, 0, .18);
  --shadow-toast: 0 8px 28px rgba(15, 23, 32, .22);
  --focus-ring: 2px solid var(--color-accent);
  --focus-ring-on-dark: 2px solid #fff;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--color-bg); color: var(--color-text); }
.hidden { display: none !important; }
.error { color: var(--color-danger); }
.ok { color: var(--color-ok); }
.warn { color: var(--color-warn); }
.hint { color: var(--color-muted); font-size: 13px; }

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
#main > header :focus-visible,
.lang-switch :focus-visible,
nav button:focus-visible {
  outline: var(--focus-ring-on-dark);
  outline-offset: 2px;
}

/* Page top bar only — scoped so it does not restyle <header> elements
   inside lead cards (.lead-head) */
#main > header { display: flex; align-items: center; gap: 20px; padding: 10px 24px;
         background: var(--color-navy); color: #fff; }
#main > header h1 { font-size: 17px; margin: 0; white-space: nowrap; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.header-right .hint { color: var(--color-header-muted); }
.header-right button { background: var(--color-navy-mid); padding: 6px 12px; font-size: 13px; }

.lang-switch {
  display: inline-flex; border: 1px solid #3a5680; border-radius: 8px;
  overflow: hidden; background: var(--color-navy-deep);
}
.lang-switch button {
  background: transparent; border: 0; color: var(--color-header-muted);
  padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.lang-switch button.active { background: #3d6bb3; color: #fff; }
.login-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.login-top h2 { margin: 0; }
.login-top .lang-switch { flex-shrink: 0; }

/* Long bilingual prose: show the active language only */
body.lang-en [data-lang="ru"],
body.lang-ru [data-lang="en"] { display: none !important; }
body:not(.lang-ru):not(.lang-en) [data-lang="ru"] { display: none !important; }
#main > header nav { display: flex; align-items: center; flex-wrap: nowrap; gap: 2px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
nav button { background: none; border: 0; color: var(--color-header-muted); padding: 8px 12px;
             font-size: 14px; cursor: pointer; border-radius: 6px;
             white-space: nowrap; }
nav button.active, nav button:hover { background: var(--color-navy-mid); color: #fff; }
.nav-menu { position: relative; }
.nav-menu-caret { font-size: 10px; opacity: .8; }
.nav-menu-list { position: absolute; top: calc(100% + 6px); right: 0;
  display: none; flex-direction: column; min-width: 185px; padding: 6px;
  background: var(--color-navy); border: 1px solid #3d5c96; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(10, 20, 40, .35); z-index: 60; }
.nav-menu.open .nav-menu-list { display: flex; }
.nav-menu-list button { width: 100%; text-align: left; }
.version-badge { background: none; border: 0; color: #8fa7cf; font-size: 11px;
  padding: 0; cursor: pointer; text-align: left; white-space: nowrap; }
.version-badge:hover { color: #fff; text-decoration: underline; }
.version-tag { background: var(--color-navy); color: #fff; font-size: 13px;
  padding: 2px 10px; border-radius: var(--radius-pill); margin-right: 6px; }
.tab { padding: 20px 24px; max-width: 1400px; }
#tab-run, #tab-report, #tab-my-leads, #tab-today, #tab-agenda { max-width: none; }
#tab-run .card, #tab-report .card { max-width: 1352px; } /* keep prose readable; table below stays full-width */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
nav .badge { margin-left: 4px; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
        padding: 18px 20px; margin-bottom: 16px; }
.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { text-align: center; min-width: 140px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--color-navy);
  font-variant-numeric: tabular-nums; }
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; width: 100%; flex-wrap: wrap; }
.card-head-row h3 { margin: 0; }
.card-head-hint { margin: 4px 0 0; }
#data-gaps-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
#data-gaps-stats .stat { min-width: 110px; padding: 10px 12px; margin: 0; }
.data-gaps-list { margin: 0 0 14px; padding-left: 18px; max-height: 220px; overflow: auto; }
.data-gaps-list code { font-size: 13px; }

button, .button { background: var(--color-navy); color: #fff; border: 0; padding: 9px 18px;
  border-radius: var(--radius-sm); font-size: 15px; cursor: pointer; text-decoration: none;
  display: inline-block; }
button:disabled { opacity: .5; cursor: default; }
button.approve-btn { background: var(--color-ok); padding: 2px 10px; font-size: 12px; }
button.secondary {
  background: var(--color-surface); color: var(--color-navy);
  border: 1px solid var(--color-border-input); margin-left: 0;
}
button.secondary:hover { background: var(--color-soft); }
button.outcome-btn {
  background: var(--color-soft); color: var(--color-navy); border: 1px solid #c5d0e0;
  padding: 4px 10px; font-size: 12px; margin: 2px; border-radius: 4px;
  cursor: pointer;
}
button.outcome-btn:hover { background: #d4e0f0; }
button.outcome-btn.outcome-active {
  background: var(--color-ok); color: #fff; border-color: var(--color-ok);
}
td.outcome-cell { white-space: nowrap; min-width: 320px; }
input[type=file], input[type=number], input[type=password], input[type=text],
input[type=search], input[type=date], select {
  border: 1px solid var(--color-border-input); border-radius: 6px; padding: 8px; font-size: 14px; }

.filerow { margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.formrow { margin: 12px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-scope { margin: 14px 0; padding: 12px 14px; border: 1px solid #d5dfeb;
                border-radius: 8px; display: flex; align-items: center;
                flex-wrap: wrap; gap: 8px 22px; }
.upload-scope legend { padding: 0 5px; color: var(--color-navy); font-weight: 600; }
.upload-scope label, .upload-scope-choice { display: inline-flex;
                                            align-items: center; gap: 7px; }
.upload-scope input[type=number] { width: 90px; }
.upload-scope .hint { flex-basis: 100%; margin: 2px 0 0; }

table { border-collapse: collapse; width: 100%; background: var(--color-surface);
        border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef2f7;
         vertical-align: top; font-size: 13.5px; }
th { background: var(--color-navy); color: #fff; position: sticky; top: 0; }
td { max-width: 420px; }
td.msgcol { max-width: none; min-width: 320px; width: 100%; white-space: pre-line; }
td.num, th.num { font-variant-numeric: tabular-nums; }

/* recent-jobs table: keep long params JSON from overlapping the status column */
#jobs-table { table-layout: fixed; }
#jobs-table th:nth-child(1) { width: 142px; } /* created */
#jobs-table th:nth-child(2) { width: 86px; }  /* kind */
#jobs-table th:nth-child(4) { width: 142px; } /* finished */
#jobs-table th:nth-child(5) { width: 74px; }  /* duration */
#jobs-table th:nth-child(6) { width: 88px; }  /* by */
#jobs-table th:nth-child(7) { width: 88px; }  /* processed */
#jobs-table th:nth-child(8) { width: 200px; } /* status */
#jobs-table th:nth-child(9) { width: 150px; } /* actions */
#jobs-table td { max-width: none; overflow-wrap: anywhere; }
#jobs-table td.job-params { white-space: nowrap; overflow: hidden;
                            text-overflow: ellipsis; color: #5a6b80;
                            font-size: 12.5px; }

/* live job progress (full bar on the run screen, compact in the jobs table) */
.job-progress-track { background: #e4ebf3; border-radius: 6px; height: 12px;
                      overflow: hidden; margin: 10px 0 6px; }
.job-progress-bar { background: var(--color-navy); height: 100%; width: 0;
                    border-radius: 6px; transition: width .6s ease; }
.job-progress-track.compact { display: inline-block; width: 110px; height: 8px;
                              margin: 0 6px 0 10px; vertical-align: middle; }
.upload-validation-progress { margin-top: 14px; max-width: 760px;
                              padding: 12px 14px; background: #f4f7fb;
                              border: 1px solid #d5dfeb; border-radius: 8px; }
.upload-progress-head { display: flex; justify-content: space-between;
                        flex-wrap: wrap; gap: 8px 16px; color: var(--color-navy); }
.upload-validation-progress .job-progress-track { margin: 8px 0 5px; }
.upload-validation-progress .hint { margin: 0; }
.job-progress-bar.indeterminate {
  width: 35% !important;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
.job-progress-bar.failed { background: var(--color-danger-strong); animation: none; }
@keyframes progress-indeterminate {
  from { transform: translateX(-110%); }
  to { transform: translateX(300%); }
}
@media (prefers-reduced-motion: reduce) {
  .job-progress-bar { transition: none; }
  .job-progress-bar.indeterminate { animation: none; }
}

/* evidence enrichment (combined run) */
.prio { display: inline-block; font-size: 11px; font-weight: 700;
        padding: 1px 8px; border-radius: 10px; margin-left: 6px;
        vertical-align: middle; background: var(--color-soft); color: var(--color-navy); }
.prio-P0 { background: var(--color-danger-strong); color: #fff; }
.prio-P1 { background: var(--color-warn); color: #fff; }
.dna-warn { font-weight: 600; }
#run-advanced { margin-top: 10px; }
#run-advanced .advanced-body { display: flex; flex-direction: column; gap: 6px;
                               padding: 10px 0 2px; }
#run-advanced input[type="number"] { width: 90px; margin: 0 6px; }
#result-filters { margin-top: 10px; gap: 18px; }
.news-flag-cell { font-weight: 600; }
.news-flag-suppressed, .news-flag-risk { color: var(--color-danger-strong); }
.news-flag-reason { color: var(--color-ok); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { text-decoration: underline; }

/* Leads table: resizable / reorderable columns + layout presets */
#my-leads-layout-toolbar { flex-wrap: wrap; align-items: center; gap: 8px 12px; }
#my-leads-layout-toolbar #my-leads-meta { margin-right: auto; }
#my-leads-layout-toolbar label { display: inline-flex; align-items: center; gap: 6px;
                                  color: #5a6a7a; font-size: 13px; }
#my-leads-layout-toolbar select { min-width: 140px; }
#my-leads-layout-toolbar button.secondary { margin-left: 0; }
#my-leads-filters { flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.filter-chip {
  border: 1px solid #c8d0e0; background: #fff; color: #33405e;
  border-radius: var(--radius-pill); padding: 4px 12px; font-size: 13px; cursor: pointer;
}
.filter-chip:hover { border-color: #8fa7cf; }
.filter-chip.filter-active {
  background: #eef3fe; border-color: #2f5fd0; color: var(--color-navy); font-weight: 600;
}
.filter-chip:disabled { opacity: .45; cursor: not-allowed; }
.chip-new { background: #e3f2fd; color: #1565c0; }
#tab-my-leads .table-scroll { overflow-x: auto; max-width: 100%; }
#my-leads-table { table-layout: fixed; width: max-content; }
#my-leads-table th, #my-leads-table td {
  max-width: none; overflow: hidden; text-overflow: ellipsis;
  position: relative;
}
#my-leads-table td.msgcol {
  white-space: pre-line; overflow: auto; text-overflow: clip;
}
#my-leads-table td.outcome-cell {
  overflow: visible; text-overflow: clip; white-space: nowrap;
}
#my-leads-table th {
  cursor: grab; padding-right: 14px;
}
#my-leads-table th.sortable .col-label { cursor: pointer; }
#my-leads-table th.sortable .col-label:hover { text-decoration: underline; }
#my-leads-table th.col-dragging { opacity: .55; }
#my-leads-table th.col-drop-before::before,
#my-leads-table th.col-drop-after::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 3px;
  background: #7eb6ff; z-index: 2;
}
#my-leads-table th.col-drop-before::before { left: 0; }
#my-leads-table th.col-drop-after::after { right: 0; }
#my-leads-table .col-resizer {
  position: absolute; top: 0; right: 0; width: 6px; height: 100%;
  cursor: col-resize; user-select: none; z-index: 3;
}
#my-leads-table .col-resizer:hover { background: rgba(255, 255, 255, .25); }
button.danger { background: var(--color-danger-strong); }
button.danger:disabled { background: #d8a5a2; cursor: not-allowed; }
.danger-zone { margin-top: 28px; border: 1px solid var(--color-danger-strong); }
.danger-zone h3 { color: var(--color-danger-strong); margin-top: 0; }
button.undo-btn { padding: 2px 10px; font-size: 12px; }

/* results history (Results tab) and the report view pager */
button.view-btn { padding: 2px 10px; font-size: 12px; background: var(--color-ok); }
.result-actions { white-space: nowrap; }
.result-actions .view-btn, .result-actions .undo-btn { margin-right: 6px; }
.result-actions .excel-link { padding: 2px 10px; font-size: 12px;
                              margin: 0 6px 0 0; }
.latest-report-link { color: var(--color-navy); font-weight: 600; }
.pager { gap: 10px; }
.pager button { padding: 4px 14px; font-size: 13px; margin: 0; }
#report-page-size { padding: 4px 8px; }

.st-done { color: var(--color-ok); } .st-failed { color: var(--color-danger); }
.st-running { color: var(--color-warn); }
.badge { background: var(--color-warn); color: #fff; font-size: 12px; padding: 2px 8px;
         border-radius: 10px; font-weight: 600; margin-left: 6px; }
.badge-soft { background: var(--color-soft); color: var(--color-navy); font-size: 12px; padding: 1px 8px;
              border-radius: 10px; font-weight: 600; margin-left: 6px; }

.manager-progress-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manager-progress-table th,
.manager-progress-table td { text-align: left; vertical-align: top;
  padding: 8px 10px; border-bottom: 1px solid #e6ebf2; }
.manager-progress-table th { color: #5b6b7c; font-weight: 600; white-space: nowrap; }
.mgr-batch-drill summary { cursor: pointer; color: var(--color-navy); font-weight: 600; }
.mgr-batch-leads { list-style: none; margin: 8px 0 0; padding: 0;
  max-height: 220px; overflow: auto; }
.mgr-batch-leads li { display: flex; justify-content: space-between; gap: 12px;
  padding: 2px 0; font-size: 12.5px; }
.mgr-lead-sent .mgr-lead-status { color: var(--color-ok); font-weight: 600; }
.mgr-lead-not-yet .mgr-lead-status { color: var(--color-warn); font-weight: 600; }

/* on-behalf sending: whose account this message goes out from */
.send-as { background: #fdf3e0; color: #8a5a00; border: 1px solid #eed9ac;
           font-size: 12px; padding: 1px 8px; border-radius: 10px;
           margin-left: 6px; white-space: nowrap; }

pre#job-log { background: #0f1720; color: #d7e3f0; padding: 14px;
  border-radius: 8px; max-height: 420px; overflow: auto; font-size: 12.5px; }

.guide { max-width: 880px; }
.guide h3 { margin-top: 0; color: var(--color-navy); }
.guide ul, .guide ol { padding-left: 22px; margin: 8px 0; }
.guide li { margin: 5px 0; }
.guide p { margin: 8px 0; }

.login { display: flex; align-items: center; justify-content: center;
         min-height: 100vh; }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-tabs { display: flex; gap: 4px; background: #eef2f7; border-radius: 8px;
              padding: 4px; }
.login-tabs button { flex: 1; background: transparent; color: #4a5a6e;
                     padding: 8px; border-radius: 6px; }
.login-tabs button.active { background: var(--color-navy); color: #fff; }
.login-pane { display: flex; flex-direction: column; gap: 10px; }
.login a { color: var(--color-navy); }
button.linkish, .linkish {
  background: none; border: none; color: var(--color-navy); padding: 0 4px;
  cursor: pointer; text-decoration: underline; font: inherit;
}
#day-sign-as { margin-left: 8px; }
#btn-edit-name { font-size: 12px; padding: 4px 8px; }

/* Model status */
.model-list { margin: 0; padding-left: 18px; }
.model-list li { margin: 4px 0; }

/* Today queue — kanban board */
.kanban-board {
  display: flex;
  gap: 12px;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 8px;
}
.kanban-col {
  flex: 1 1 0;
  min-width: 280px;
  max-width: 360px;
  background: #f3f6fa;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
}
.kanban-col-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: #eaf0f7;
  border-bottom: 1px solid var(--color-border);
  border-radius: 12px 12px 0 0;
}
.kanban-col-head h3 {
  margin: 0;
  color: var(--color-navy);
  font-size: 15px;
}
.kanban-col-body {
  overflow-y: auto;
  padding: 10px;
  flex: 1;
}
.kanban-col .queue-subsection { margin: 0 0 12px; }
.kanban-col .queue-subsection h4 {
  color: var(--color-accent); margin: 0 0 8px; font-size: 12px; font-weight: 600;
}
.kanban-col .lead-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: none;
}
.kanban-col .lead-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}
.kanban-col .lead-card.lead-dead { border-color: var(--color-warn-border); background: var(--color-warn-bg); }
.lead-summary {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font: inherit;
}
.lead-summary:hover { background: #f7f9fc; }
.lead-summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.lead-summary-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  min-width: 0;
}
.lead-summary-id strong {
  font-size: 13.5px;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.lead-expand-hint {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-top: 6px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #8a9bb0;
  transition: transform .15s ease;
}
.lead-card.expanded .lead-expand-hint { transform: rotate(180deg); }
.lead-summary-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-muted-2);
}
.card-ev b { color: var(--color-navy); }
.card-chip {
  display: inline-block;
  background: var(--color-soft);
  color: var(--color-navy);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 8px;
  line-height: 1.4;
}
.chip-hot { background: #ffe8cc; color: var(--color-warn); }
.chip-dead { background: #f0e6d2; color: #7a5a20; }
.chip-fu { background: #fff3cd; color: #856404; }
.chip-refreshed { background: #d7f0dd; color: var(--color-ok); }
.chip-refreshing { background: #fff3cd; color: #856404; }
.chip-claimed { background: #e3e0f7; color: #4b3f9e; }
.chip-manager { background: #e2edf7; color: #1f5d8f; }
.lead-summary .plan-check {
  margin-left: auto;
  margin-right: 0;
  font-size: 12px;
}
.lead-detail {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--color-soft);
}
.lead-card.expanded .lead-detail { display: block; padding-top: 10px; }
.lead-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--color-muted-2);
  margin-bottom: 8px;
}
.lead-detail-meta b { color: var(--color-navy); }
.kanban-col .lead-msg { max-height: 160px; font-size: 13px; }
.kanban-col .lead-why { font-size: 12.5px; margin: 4px 0 6px; }
.kanban-col .lead-angle { font-size: 13px; }
.kanban-col .fu-due { padding: 8px 10px; margin: 8px 0; }
.kanban-col .lead-actions button { font-size: 13px; padding: 6px 12px; }

@media (max-width: 900px) {
  .kanban-board {
    flex-direction: column;
    overflow-x: visible;
  }
  .kanban-col {
    max-width: none;
    min-width: 0;
    max-height: none;
  }
  .kanban-col-body { overflow-y: visible; }
}

/* Legacy section styles kept for any residual uses */
.queue-section { margin-bottom: 28px; }
.queue-section h3 { color: var(--color-navy); margin: 0 0 12px; }
.queue-subsection { margin: 0 0 18px; }
.queue-subsection h4 {
  color: var(--color-accent); margin: 0 0 10px; font-size: 14px; font-weight: 600;
}
.lead-cards { display: flex; flex-direction: column; gap: 14px; max-width: 920px; }
.lead-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 16px 18px;
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
}
.lead-card.lead-dead { border-color: var(--color-warn-border); background: var(--color-warn-bg); }
.lead-head { display: flex; justify-content: space-between; gap: 16px;
             flex-wrap: wrap; margin-bottom: 8px; }
.lead-rank { color: var(--color-muted); margin-right: 6px; font-weight: 600; }
.lead-metrics { display: flex; gap: 14px; flex-wrap: wrap; color: var(--color-muted-2);
                font-size: 13px; font-variant-numeric: tabular-nums; }
.lead-metrics b { color: var(--color-navy); }
.lead-why { margin: 6px 0 8px; padding-left: 18px; color: var(--color-muted-2); font-size: 13.5px; }
.lead-angle { margin: 4px 0 10px; font-size: 14px; }
.lead-msg-wrap { background: #f7f9fc; border: 1px solid #e4ebf3; border-radius: 8px;
                 padding: 12px; }
.lead-subject { margin: 0 0 8px; padding-bottom: 8px;
                border-bottom: 1px dashed #d5dfe9; font-size: 14px; }
.lead-subject-text { color: var(--color-text); word-break: break-word; }
.vector-summary { margin: 8px 0 12px; }
.vector-drilldown summary { cursor: pointer; }
.vector-lead { margin: 6px 0; padding: 6px 10px; background: #f7f9fc;
               border: 1px solid #e4ebf3; border-radius: 8px; }
.vector-lead summary { cursor: pointer; }
.vector-detail { margin: 6px 0 6px 12px; }
.vector-detail ul { margin: 4px 0 0 16px; padding: 0; }
.vector-winner { border-left: 3px solid #3f8f4f; padding-left: 8px; }
.lead-msg {
  margin: 0 0 10px; white-space: pre-wrap; word-break: break-word;
  font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--color-text); max-height: 220px; overflow: auto;
}
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lead-actions .secondary { margin-left: 0; }
.copy-blocked { color: var(--color-danger-strong); font-size: 12px; font-weight: 600; }
.plan-check {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--color-navy); cursor: pointer; user-select: none; margin-right: 4px;
}
.plan-check input { cursor: pointer; }
#day-bar { border-left: 4px solid var(--color-accent); }
#day-status { font-weight: 500; }

/* Follow-up due block on lead cards */
.fu-due {
  border: 1px solid var(--color-warn-border); background: var(--color-warn-bg); border-radius: var(--radius);
  padding: 12px 14px; margin: 10px 0;
}
.fu-due .fu-head { color: var(--color-warn); margin-bottom: 8px; }
.fu-due pre.lead-msg { margin: 8px 0; }

/* Conversation plan expander */
.conv-plan { margin-top: 10px; border-top: 1px dashed var(--color-border); padding-top: 8px; }
.conv-plan summary {
  cursor: pointer; color: var(--color-accent); font-size: 14px; font-weight: 600;
  user-select: none;
}
.conv-plan .plan-body { margin-top: 10px; }
.conv-plan h4 { color: var(--color-navy); margin: 14px 0 8px; }
.plan-pair { margin: 10px 0 14px; }
.plan-quote { color: #444; margin-bottom: 6px; }
.plan-answer pre.lead-msg { margin: 6px 0; }
.plan-experiment {
  border-left: 3px solid var(--color-warn); padding-left: 10px; margin: 10px 0;
}
.plan-copy { font-size: 12px; padding: 3px 10px; }
.pill {
  display: inline-block; background: var(--color-soft); color: var(--color-navy);
  font-size: 11px; padding: 1px 7px; border-radius: 8px; margin-left: 8px;
  vertical-align: middle;
}

/* Start-my-day blocking overlay — sits above modals so the manager cannot
   click through while the rewrite job is still running. */
.day-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 32, .72);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.day-overlay-card {
  background: #fff; border-radius: 14px; padding: 32px 36px;
  width: min(520px, 100%); text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.day-overlay-card h2 {
  margin: 18px 0 10px; color: var(--color-navy); font-size: 26px; line-height: 1.25;
}
.day-overlay-progress {
  margin: 0 0 14px; color: var(--color-navy); font-size: 16px; font-weight: 600;
  min-height: 1.3em;
}
.day-overlay-body {
  margin: 0; color: #3a4a5c; font-size: 17px; line-height: 1.45;
}
.day-overlay-spinner {
  width: 44px; height: 44px; margin: 0 auto;
  border: 4px solid #d5dfeb; border-top-color: var(--color-navy);
  border-radius: 50%; animation: day-spin 0.9s linear infinite;
}
@keyframes day-spin { to { transform: rotate(360deg); } }

/* Lightweight loading overlay after login while the first tab's data loads */
.app-loading {
  position: fixed; inset: 0; background: rgba(15, 23, 32, .35);
  display: flex; align-items: center; justify-content: center;
  z-index: 190; padding: 24px;
}
.app-loading-card {
  background: #fff; border-radius: 14px; padding: 26px 34px;
  text-align: center; box-shadow: 0 12px 36px rgba(0, 0, 0, .22);
}
.app-loading-text {
  margin: 14px 0 0; color: var(--color-navy); font-size: 17px; font-weight: 600;
}

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 32, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
  overscroll-behavior: contain;
}
.modal-card {
  background: #fff; border-radius: 12px; padding: 22px 24px;
  width: min(480px, 100%); box-shadow: var(--shadow-modal);
}
.modal-card h3 { margin: 0 0 4px; color: var(--color-navy); }
.outcome-events, .outcome-types { display: flex; flex-wrap: wrap; gap: 4px;
                                  margin: 10px 0 14px; }

@media (max-width: 640px) {
  #main > header { flex-wrap: wrap; gap: 8px; }
  .lead-head { flex-direction: column; }
  .tab { padding: 14px; }
}

/* Agenda */
.agenda-header-card h3 { color: var(--color-navy); }
.agenda-toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  position: sticky; top: 0; z-index: 5;
  background: var(--color-bg); padding: 8px 0 12px; margin-bottom: 4px;
}
.agenda-search-wrap, .lead-search-wrap {
  display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; min-width: 180px;
}
.agenda-search-wrap label, .lead-search-wrap label {
  font-size: 12px; color: var(--color-muted); font-weight: 600;
}
.agenda-search-row, .lead-search-row {
  display: flex; align-items: center; gap: 6px;
}
.agenda-search-row input[type=search],
.lead-search-row input[type=search] {
  flex: 1; min-width: 0;
}
.agenda-search-meta, .lead-search-meta {
  font-size: 12px; color: var(--color-muted); min-height: 1.2em;
}
.agenda-strip {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 16px;
  margin-bottom: 8px;
}
.agenda-day {
  flex: 0 0 auto; min-width: 64px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 8px; padding: 8px 6px;
  text-align: center; cursor: pointer; user-select: none;
  color: inherit; font: inherit;
}
.agenda-day:hover { border-color: var(--color-accent); }
.agenda-day.active { border-color: var(--color-navy); background: var(--color-soft); }
.agenda-day.is-today { border-color: var(--color-accent); }
.agenda-day.is-overdue { border-color: var(--color-warn-border); background: var(--color-warn-bg); }
.agenda-day .ad-label { font-size: 11px; color: var(--color-muted); display: block; }
.agenda-day .ad-count {
  display: block; font-size: 18px; font-weight: 700; color: var(--color-navy);
  line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums;
}
.agenda-day .ad-bar {
  height: 4px; background: #e4ebf3; border-radius: 2px; overflow: hidden;
  margin-top: 4px;
}
.agenda-day .ad-bar > span {
  display: block; height: 100%; background: var(--color-accent); width: 0;
}
.agenda-day.is-overdue .ad-bar > span { background: var(--color-warn); }
.agenda-item {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 14px 16px;
}
.agenda-item.overdue { border-color: var(--color-warn-border); background: var(--color-warn-bg); }
.agenda-item .ai-type {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 8px; background: var(--color-soft); color: var(--color-navy);
  margin-right: 6px;
}
.agenda-item.overdue .ai-type { background: #f5e6c8; color: var(--color-warn); }
.agenda-item .ai-due { color: var(--color-warn); font-size: 13px; font-weight: 600; }
.agenda-item .ai-due.ok { color: var(--color-ok); }
.agenda-item mark, .lead-card mark, .agenda-not-in mark {
  background: #ffe08a; color: inherit; padding: 0 2px; border-radius: 2px;
}
.agenda-send-state {
  display: inline-block; margin-right: 6px; padding: 2px 8px;
  border-radius: 8px; background: #fff3cd; color: #856404;
  font-size: 11px; font-weight: 700;
}
.agenda-snooze-menu { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.agenda-not-in-list { display: flex; flex-direction: column; gap: 10px; max-width: 920px; }
.agenda-not-in {
  background: var(--color-surface); border: 1px dashed #c5d0e0; border-radius: var(--radius);
  padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.agenda-not-in .lead-actions { margin-top: 0; }
.panel-state { padding: 18px 20px; }
.panel-state .error { margin: 0 0 10px; }
.panel-state button { margin-top: 4px; }

/* Toasts */
.toast-host {
  position: fixed; right: 16px; bottom: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--color-navy); color: #fff; border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-toast);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 14px; line-height: 1.35;
}
.toast.toast-ok { background: var(--color-ok); }
.toast.toast-error { background: var(--color-danger-strong); }
.toast.toast-warn { background: var(--color-warn); }
.toast-body { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.toast-action {
  background: rgba(255,255,255,.18); color: #fff; border: 0;
  padding: 4px 10px; border-radius: 6px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.toast-action:hover { background: rgba(255,255,255,.28); }
.toast-dismiss {
  background: transparent; border: 0; color: rgba(255,255,255,.85);
  font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer;
}

/* Confirm / prompt dialog */
#ui-dialog .modal-card { width: min(440px, 100%); }
#ui-dialog-message { margin: 10px 0 14px; white-space: pre-wrap; }
#ui-dialog-input { width: 100%; margin-bottom: 12px; }
#ui-dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }

.ab-arm-subject { margin: 0 0 6px; }
.ab-arm-body { white-space: pre-wrap; margin: 0; }

/* News snapshot history and read-only detail view */
.table-scroll { overflow-x: auto; }
#news-snapshots-table { min-width: 640px; }
#news-snapshots-table th:nth-child(1) { width: 32%; }
#news-snapshots-table th:nth-child(2) { width: 18%; }
#news-snapshots-table a, .news-event-sources a, .news-back-link {
  color: var(--color-accent);
}
.news-card-heading {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.news-card-heading h3 { margin: 0; }
.news-card-heading button.secondary { margin-left: 0; }
.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; margin-top: 14px;
}
.pagination button { padding: 5px 12px; font-size: 13px; }
.pagination button.secondary { margin-left: 0; }

.news-page { width: min(1080px, 100%); margin: 0 auto; padding: 24px; }
.news-page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.news-page-header h1 { margin: 6px 0 0; color: var(--color-navy); font-size: 26px; }
.news-back-link { font-size: 13px; }
.news-snapshot-meta {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 18px; margin: 0;
}
.news-snapshot-meta dt { color: var(--color-muted); font-size: 13px; }
.news-snapshot-meta dd { margin: 0; overflow-wrap: anywhere; }
.news-events-list { display: flex; flex-direction: column; gap: 12px; }
.news-event {
  border: 1px solid var(--color-border); border-radius: 9px; padding: 14px 16px;
  background: #f9fbfd;
}
.news-event h3 { margin: 0 0 8px; color: var(--color-navy); font-size: 17px; }
.news-event-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.news-event-chip {
  display: inline-block; border-radius: 9px; padding: 2px 8px;
  background: var(--color-soft); color: var(--color-navy); font-size: 11px; font-weight: 600;
}
.news-event-chip.severity-critical, .news-event-chip.severity-high,
.news-event-chip.news-risk-chip { background: #f8dddd; color: #9f1d16; }
.news-event-chip.severity-medium { background: #fff3cd; color: #856404; }
.news-event-field { margin: 5px 0; overflow-wrap: anywhere; }
.news-event-field strong { color: #43536a; }
.news-event-sources { display: flex; flex-wrap: wrap; gap: 8px 16px;
                       margin-top: 10px; font-size: 13px; }

@media (max-width: 640px) {
  .news-page { padding: 14px; }
  .news-snapshot-meta { grid-template-columns: 1fr; gap: 1px; }
  .news-snapshot-meta dd { margin-bottom: 7px; }
  .pagination { justify-content: space-between; }
  .toast-host { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}
