:root {
  font-family: Arial, "Liberation Sans", sans-serif;
  color: #1b3047;
  background: #eaf0f4;
  font-synthesis: none;
  --ink: #1b3047;
  --muted: #4a5d70;
  --line: #c7d3de;
  --navy: #182f47;
  --navy-mid: #244b6c;
  --surface: #ffffff;
  --accent: #f3a34e;
  --radius: 3px;
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
button, input, select { font: inherit; }
a { color: #145681; text-underline-offset: 3px; }
button, a[href], summary, select, input[type="checkbox"], .group-options label {
  cursor: pointer;
}
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #b85b00; outline-offset: 2px; }
[hidden] { display: none !important; }
button:disabled, select:disabled, input:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.app-header {
  background: var(--navy);
  border-top: 4px solid var(--accent);
  min-height: 82px;
  padding: 18px max(28px, calc((100vw - 1500px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.wordmark {
  font-size: clamp(20px, 2.2vw, 24px);
  font-weight: 800;
  letter-spacing: -0.6px;
  color: #ffffff;
  text-decoration: none;
  line-height: 1;
}
.wordmark > span { color: #ffc582; margin-left: 5px; }
.wordmark small {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: #d0dce7;
  margin-top: 8px;
}
.header-note { font-size: 12px; color: #d0dce7; }
.header-note > span { color: #90a9bf; margin: 0 10px; }

main { max-width: 1556px; margin: auto; padding: 24px 28px 28px; }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 2.5vw, 28px);
  letter-spacing: -0.6px;
  font-weight: 700;
  line-height: 1.2;
}
.intro {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 68ch;
}
.scan-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

button {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid #9db2c4;
  border-radius: var(--radius);
  padding: 10px 15px;
  min-height: 40px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
}
button:hover:not(:disabled) { background: #edf3f8; border-color: #6d89a2; }
button:active:not(:disabled) { background: #dce8f2; }
.button-primary {
  background: var(--accent);
  color: #192e42;
  border-color: #c77e31;
}
.button-primary:hover:not(:disabled) { background: #ffc280; border-color: #a8641d; }
.button-quiet { color: #164970; background: transparent; border-color: #b7c8d6; }
.button-stop { color: #8f2418; background: #fdeceb; border-color: #c9867d; }
.button-stop:hover:not(:disabled) { background: #fadbd8; border-color: #a6463b; }

.scan-alert {
  background: #fdeceb;
  color: #8f2418;
  border: 1px solid #d49087;
  border-left: 4px solid #8f2418;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.group-chooser {
  border: 1px solid #b5c6d4;
  background: #dfe9f1;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.group-chooser > summary { color: #1e374e; font-size: 12px; font-weight: 600; }
.group-chooser > summary > span { float: right; color: #3d566c; font-weight: 400; font-size: 11px; }
.group-chooser > .meta { margin-top: 10px; }
.group-selection-actions { display: flex; gap: 8px; margin: 12px 0; }
.group-selection-actions button { min-height: 36px; padding: 6px 12px; }
.group-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}
.group-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 400;
}
.group-options input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex-shrink: 0;
  accent-color: var(--navy-mid);
}

.filter-panel {
  background: var(--surface);
  border: 1px solid #b8c8d6;
  border-top: 3px solid var(--navy-mid);
  padding: 20px 22px 6px;
  border-radius: var(--radius);
}
label {
  display: grid;
  gap: 6px;
  color: #2f4558;
  font-size: 11px;
  font-weight: 600;
  min-width: 0;
}
input, select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid #9fb4c7;
  border-radius: var(--radius);
  background: #f7f9fb;
  color: var(--ink);
  padding: 9px 11px;
  min-height: 40px;
  font-size: 12px;
}
input:hover, select:hover { border-color: #5c7a94; }

#keywords-form {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin: 0 0 18px;
  padding-bottom: 18px;
}
#keywords-form label { flex: 1; }
#keywords, #exclude { background: #ffffff; }
#keywords-form button {
  background: var(--navy-mid);
  border-color: var(--navy-mid);
  color: #ffffff;
  white-space: nowrap;
}
#keywords-form button:hover:not(:disabled) { background: #173a57; border-color: #173a57; }
#keyword-save-status {
  position: absolute;
  bottom: 0;
  left: 0;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
}

.quick-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  padding: 0 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e1e7ed;
}
.date-shortcuts, .job-shortcuts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.date-shortcuts > span, .job-shortcuts > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
.date-shortcuts button, .job-shortcuts button {
  background: #edf2f7;
  color: var(--ink);
  min-height: 34px;
  padding: 6px 11px;
  font-size: 11px;
  border: 1px solid #c3d1dd;
}
.job-shortcuts button[aria-pressed="true"] {
  background: #1e4a6f;
  color: #ffffff;
  border-color: #163754;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(270px, 1.4fr) 1fr 1fr;
  gap: 20px;
  padding-bottom: 16px;
}
.date-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; min-width: 0; }
.date-separator { align-self: end; padding-bottom: 11px; color: var(--muted); font-size: 12px; }
.filter-footer {
  padding: 8px 0 6px;
  border-top: 1px solid #e1e7ed;
}
.extra-filters { width: 100%; }
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  padding: 12px 0 6px;
}
summary { cursor: pointer; color: #1b4e74; font-size: 12px; font-weight: 600; padding: 4px 0; }
summary:hover { color: #8c4300; }

.scan-progress {
  margin: 16px 0 5px;
  font-size: 12px;
  line-height: 1.6;
  color: #2f4a61;
  overflow-wrap: anywhere;
}
.scan-details > summary { font-size: 11px; color: var(--muted); font-weight: 600; }
.scan-details { margin-bottom: 0; }
#status {
  background: #f7ecdb;
  border-left: 3px solid #b87324;
  padding: 12px 15px;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.6;
}
#scan-freshness { margin-top: 8px; line-height: 1.6; }
#scan-groups { list-style: none; padding: 0; }
#scan-groups li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
#scan-groups p { margin: 5px 0; }

.results-section { margin-top: 24px; }
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 12px;
  border-bottom: 2px solid var(--navy-mid);
}
h2 { font-size: 20px; letter-spacing: -0.4px; margin: 0; font-weight: 700; }
#count {
  font-size: 12px;
  color: #4b351d;
  font-weight: 700;
  background: #fbdcb6;
  padding: 7px 12px;
  border-radius: var(--radius);
}
.results-context {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 12px 0;
}
.meta, #feedback { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
#feedback { max-width: 68%; text-align: right; }

.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid #b8c8d6;
  border-radius: var(--radius);
}
table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  background: #24435e;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 13px 15px;
  border-right: 1px solid #3d5b74;
}
th:first-child { width: 126px; }
th:nth-child(2) { width: 20%; }
th:last-child { width: 176px; border-right: 0; }
td {
  vertical-align: top;
  overflow-wrap: anywhere;
  border-bottom: 1px solid #dce4eb;
  border-right: 1px solid #edf1f5;
  padding: 15px;
  font-size: 13px;
  line-height: 1.6;
}
.post:nth-child(even) { background: #f7fafc; }
.post:hover { background: #edf4fa; }
.post.is-dismissed { opacity: 0.62; }
.post.is-contacted { background: #f2f9f4; }
tr:last-child td { border-bottom: 0; }
td:last-child { border-right: 0; }

.date-cell > span {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #254b6b;
}
.date-cell small { margin-top: 4px; }
.group-cell a {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  color: #145681;
  text-decoration: none;
}
.group-cell a:hover { text-decoration: underline; }

.job-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.signal-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.signal-demand { background: #e3f5ea; color: #14532d; border-color: #a8d9ba; }
.signal-carrier { background: #f9efd8; color: #5d4310; border-color: #dfca96; }
.signal-route { background: #e5f0f8; color: #164466; border-color: #b4cfe3; }
.signal-fit-ok { background: #e3f5ea; color: #14532d; border-color: #a8d9ba; }
.signal-fit-warn { background: #fdeceb; color: #8f2418; border-color: #e4b1aa; }
.signal-status { background: #edf2f7; color: #2b4459; border-color: #c2d0dc; }

.text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.65;
  color: #1c3246;
}
.source-cell { display: table-cell; }
.source-cell a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 11px;
  border: 1px solid #8caac0;
  border-radius: var(--radius);
  padding: 6px 10px;
  min-height: 32px;
  background: #edf4f9;
  color: #145681;
  white-space: nowrap;
}
.source-cell a:hover { background: #dfeef7; border-color: #5b82a0; }
.source-actions { display: grid; gap: 7px; margin-top: 8px; }
.source-cell button {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 0;
}
.source-cell button[aria-pressed="true"] {
  background: #fbdcb6;
  border-color: #b87b33;
  color: #4b351d;
}
.review-control, .lead-control { margin-top: 4px; font-size: 10px; gap: 3px; }
.review-control select, .lead-control select { min-height: 32px; padding: 5px 7px; font-size: 11px; }
.review-feedback { margin-top: 4px; font-size: 11px; color: var(--muted); }

.duplicate-note { margin-top: 8px; color: #6e450a; font-weight: 600; }
.post-details, .full-post, .duplicate-copies { margin-top: 8px; }
.post-details summary, .full-post summary { font-size: 11px; color: #2a5374; }
.post-details p { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 4px 0; }
.full-post .text { padding-top: 8px; }
.duplicate-copies > summary { font-weight: 600; font-size: 11px; }
.duplicate-copies ul { padding-left: 18px; font-size: 12px; line-height: 1.6; margin: 6px 0 0; }
.duplicate-copies li { margin: 6px 0; }
.duplicate-copies small { margin-top: 2px; }

small { display: block; font-size: 11px; color: var(--muted); }
mark { background: #ffdf93; color: #362709; border-radius: 1px; padding: 1px 2px; }
#load-more {
  display: block;
  margin: 20px auto 0;
  background: #24435e;
  color: #ffffff;
  border-color: #24435e;
  min-width: 180px;
}
#load-more:hover:not(:disabled) { background: #18324a; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding-top: 16px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}
footer > span:first-child { font-weight: 700; color: #244b6c; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1020px) {
  .page-heading { align-items: flex-start; flex-wrap: wrap; }
  .filter-row { grid-template-columns: 1fr 1fr; gap: 14px; }
  .date-controls { grid-column: 1 / -1; }
  td { padding: 13px 12px; }
  th { padding: 12px; }
  th:last-child { width: 158px; }
}

@media (max-width: 720px) {
  .app-header { padding: 16px; min-height: 74px; }
  .header-note { max-width: 115px; font-size: 10px; text-align: right; line-height: 1.5; }
  .header-note > span { margin: 0 4px; }
  main { padding: 18px 12px 24px; }
  .page-heading { display: block; margin-bottom: 16px; }
  .scan-controls { justify-content: flex-start; gap: 8px; margin-top: 14px; }
  .scan-controls button { flex: 1 1 calc(50% - 4px); min-height: 44px; padding: 10px 8px; font-size: 12px; }
  .scan-controls .button-quiet { order: 4; flex-basis: 100%; min-height: 44px; text-align: center; }

  .filter-panel { padding: 16px 14px 8px; }
  #keywords-form { flex-wrap: wrap; gap: 10px; }
  #keywords-form label { flex-basis: 100%; }
  #keywords-form button { width: 100%; min-height: 44px; }
  .date-shortcuts button, .job-shortcuts button { min-height: 44px; padding: 8px 12px; font-size: 12px; }
  .filter-row { grid-template-columns: 1fr; gap: 12px; }
  .date-controls { grid-template-columns: 1fr; gap: 8px; }
  .date-separator { display: none; }
  .group-options { grid-template-columns: 1fr; }
  .group-options label { min-height: 40px; }
  .group-selection-actions button { min-height: 44px; flex: 1; }
  .toolbar { grid-template-columns: 1fr; }

  .summary { align-items: flex-end; gap: 10px; }
  #count { font-size: 11px; padding: 7px 10px; }
  #feedback { max-width: 100%; width: 100%; text-align: left; }

  .table-scroll { overflow: visible; background: transparent; border: 0; }
  table, tbody { display: block; width: 100%; min-width: 0; }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  tr.post {
    display: grid;
    grid-template-columns: 1fr;
    background: var(--surface);
    border: 1px solid #b8c8d6;
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 14px;
    gap: 8px;
  }
  .post:nth-child(even) { background: var(--surface); }
  .post.is-contacted { background: #f2f9f4; }
  tr.post td {
    display: block;
    border: 0;
    padding: 0;
    width: auto;
  }
  .date-cell { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
  .date-cell small { display: inline; margin-top: 0; }
  .source-cell { padding-top: 10px; border-top: 1px solid #e1e7ed; }
  .source-cell a, .source-cell button, .review-control select, .lead-control select { min-height: 44px; font-size: 12px; }
  .source-cell a { width: 100%; justify-content: center; }
  .post-details summary, .full-post summary, .duplicate-copies > summary { padding: 8px 0; }
  footer { flex-direction: column; gap: 6px; margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
