/* FGA Pitch — the op-ed desk.
   Two faces: Roboto Slab (stand-in for FGA's Serifa) carries the headlines —
   editor names, pitch headlines, page titles. Open Sans does the work.
   Brand: navy chrome, 3px med-blue rules, sharp corners, uppercase on buttons
   only. Status colors are semantic (rails + pills), never decoration. */

:root {
  --navy: #0D224D;
  --blue: #0093D0;
  --blue-deep: #007CB0;
  --lblue: #1EBDFF;
  --green: #709E40;
  --gold: #F9C213;
  --red: #D12123;

  --ink: #232A33;
  --text: #3F474F;
  --muted: #6E7781;
  --faint: #A9B2BC;
  --paper: #F4F6F9;
  --card: #FFFFFF;
  --tint: #EEF5FA;
  --hover: #E1EFF7;
  --rule: #DDE3EA;
  --rule-strong: #C2CBD5;

  --serif: 'Roboto Slab', Georgia, 'Times New Roman', serif;
  --sans: 'Open Sans', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
}

h1, h2, h3 { color: var(--navy); line-height: 1.2; }
h1 { font-family: var(--serif); font-weight: 700; font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 700; }

a { color: var(--blue-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; color: inherit; }
svg { flex-shrink: 0; }
a svg, .info-v svg { display: inline-block; vertical-align: -2px; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: -1px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); }
::-webkit-scrollbar-track { background: transparent; }

/* ── Login (only shown when a sign-in round-trip failed) ───────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-logo { display: block; height: 32px; width: auto; margin: 0 auto 28px; }
.login-card { background: var(--card); border-top: 3px solid var(--blue); padding: 28px 28px 26px; }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.login-card p { color: var(--muted); margin-bottom: 20px; max-width: 34ch; }
.login-btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: var(--blue);
  border: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.login-btn:hover { background: var(--blue-deep); }
.login-error { color: var(--red); font-size: 12px; margin-top: 14px; }

/* ── Header ──────────────────────────────────────────────────────────────── */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.hdr {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: stretch;
  gap: 28px;
  height: 56px;
  padding: 0 24px;
  background: var(--navy);
  border-bottom: 3px solid var(--blue);
}
.hdr-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.hdr-brand:hover { text-decoration: none; }
.hdr-brand img { height: 26px; width: auto; }
.hdr-wordmark {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.25);
  line-height: 1;
}

.hdr-nav { display: flex; gap: 4px; flex-shrink: 0; }
.tab {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  border-bottom: 3px solid transparent;
  margin-bottom: -3px;
}
.tab:hover { color: #fff; text-decoration: none; }
.tab.on { color: #fff; border-bottom-color: var(--gold); }

.hdr-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: auto; }
#user-name { font-size: 12px; color: rgba(255,255,255,.75); white-space: nowrap; }
.hdr-signout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.85);
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.hdr-signout:hover { border-color: #fff; color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.main { flex: 1; padding: 22px 24px 40px; max-width: 1640px; width: 100%; }
.loading, .empty { padding: 36px 0; color: var(--muted); }
.empty { max-width: 46ch; line-height: 1.55; }
.empty strong { display: block; color: var(--navy); font-weight: 700; margin-bottom: 4px; }

.panel { background: var(--card); border: 1px solid var(--rule); }

.page-err, .form-err {
  background: #FBECEC;
  border-left: 3px solid var(--red);
  color: #7F1214;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
}

.view-hdr { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; }
.view-hdr .spacer { flex: 1; }
.view-hdr .lede { color: var(--muted); }

/* ── Buttons — the one place uppercase lives (brand) ─────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--blue);
  border: 1px solid var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--rule-strong); color: var(--navy); }
.btn-ghost:hover { background: #fff; border-color: var(--navy); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #AB1A1C; border-color: #AB1A1C; }
.btn-sm { padding: 5px 9px; font-size: 10px; letter-spacing: 0.07em; }

.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid var(--rule-strong);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.btn-toggle:hover { border-color: var(--navy); color: var(--navy); }
.btn-toggle.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.ibtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--faint);
  cursor: pointer;
}
tr:hover .ibtn, .ph:hover .ibtn, .info-v .ibtn { color: var(--muted); }
.ibtn:hover { border-color: var(--rule-strong); color: var(--navy); background: #fff; }
.ibtn.danger:hover { border-color: var(--red); color: var(--red); }
.ibtn.done { color: var(--green); }

.star { display: inline-flex; align-items: center; background: none; border: 0; cursor: pointer; color: var(--rule-strong); padding: 2px; }
.star.on, .star:hover { color: var(--gold); }

/* ── Inputs ──────────────────────────────────────────────────────────────── */

input[type=text], input[type=email], input[type=date], input[type=url], select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: 7px 9px;
}
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.search-wrap { position: relative; flex: 0 1 320px; min-width: 200px; }
.search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input { width: 100%; padding-left: 30px; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar select { max-width: 240px; }

.result-line { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.result-line b { color: var(--navy); font-weight: 700; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.tbl-wrap {
  overflow: auto;
  max-height: calc(100vh - 176px);
  background: var(--card);
  border: 1px solid var(--rule);
}
/* Below this width the wrapper scrolls rather than crushing columns. */
table { width: 100%; min-width: 1120px; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 10px 10px 8px;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 var(--navy);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--navy); }
thead th.sorted { color: var(--navy); }
thead th .arrow { color: var(--blue); font-size: 9px; margin-left: 3px; }

tbody td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:nth-child(even) { background: var(--tint); }
tbody tr:hover { background: var(--hover); }
tbody tr.clickable { cursor: pointer; }

td.num { text-align: right; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
td.date, th.date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
td.acts { white-space: nowrap; width: 1%; }
td.tight, th.tight { width: 1%; white-space: nowrap; }

.cell-outlet { color: var(--muted); }
.cell-editor { font-family: var(--serif); font-size: 14px; font-weight: 700; color: var(--navy); }
.cell-editor.generic { font-family: var(--sans); font-size: 13px; font-style: italic; font-weight: 400; color: var(--muted); }
.cell-headline { font-family: var(--serif); font-size: 14px; font-weight: 700; color: var(--navy); min-width: 260px; max-width: 460px; line-height: 1.35; }
.cell-headline a { color: var(--navy); }
.cell-headline a:hover { color: var(--blue-deep); }
.cell-headline svg { color: var(--faint); }
.cell-notes { color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash { color: var(--faint); }

/* 3px status rail on the first cell of every editor row. */
td.rail { border-left: 3px solid transparent; width: 1%; padding-left: 8px; }
tr.st-active td.rail { border-left-color: var(--green); }
tr.st-new td.rail { border-left-color: var(--lblue); }
tr.st-changed td.rail { border-left-color: var(--gold); }
tr.st-inactive td.rail { border-left-color: var(--red); }

.sel-status {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--text);
  max-width: 140px;
}
.sel-status:hover { border-color: var(--rule-strong); }

.email-cell { display: flex; align-items: center; gap: 5px; }
.email-cell a { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pager { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 12px; color: var(--muted); }
.pager .btn { padding: 5px 10px; font-size: 10px; }

/* ── Status pills — tinted, sentence case ────────────────────────────────── */

.pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.pill.sent { background: #E3F3FB; color: #005F87; border-color: var(--blue); }
.pill.landed { background: #EDF4E3; color: #3F5F1E; border-color: var(--green); }
.pill.declined { background: #FBE9E9; color: #8B1518; border-color: var(--red); }
.pill.no_response { background: #FDF5D9; color: #6E5300; border-color: var(--gold); }
.pill.withdrawn { background: #EEF0F2; color: var(--muted); border-color: var(--faint); }

/* ── Pipeline tabs (Pitches view) — counts are the structure ─────────────── */

.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule-strong); margin-bottom: 14px; }
.subtab {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.subtab:hover { color: var(--navy); }
.subtab.on { color: var(--navy); border-bottom-color: var(--blue); }
.subtab .n { font-size: 12px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.subtab.on .n { color: var(--blue-deep); }

/* ── Editor detail ───────────────────────────────────────────────────────── */

.back-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.back-link:hover { color: var(--navy); text-decoration: none; }

.band {
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--blue);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.band.st-active { border-left-color: var(--green); }
.band.st-new { border-left-color: var(--lblue); }
.band.st-changed { border-left-color: var(--gold); }
.band.st-inactive { border-left-color: var(--red); }
.band-main { min-width: 260px; }
.band-outlet { font-size: 13px; font-weight: 600; color: var(--blue-deep); margin-bottom: 4px; }
.band-name { font-size: 30px; }
.band-name.generic { font-family: var(--sans); font-size: 22px; font-style: italic; font-weight: 400; color: var(--muted); }
.band-title { color: var(--muted); margin-top: 3px; }
.band-acts { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; padding-top: 4px; }

.grid2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }

.card-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
.card-hd h2 { font-size: 13px; font-weight: 700; color: var(--navy); }
.card-hd .spacer { flex: 1; }
.card-hd .count { font-size: 12px; color: var(--muted); }
.card-bd { padding: 14px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px 18px; }
.info-k { font-size: 12px; color: var(--muted); margin-bottom: 1px; }
.info-v { display: flex; align-items: center; gap: 5px; word-break: break-word; color: var(--ink); }
.info-v.empty-v { color: var(--faint); }

.notes-body { white-space: pre-wrap; max-width: 62ch; }
.notes-empty { color: var(--faint); font-style: italic; }
.notes-edit textarea { width: 100%; min-height: 100px; }
.notes-edit .row { display: flex; gap: 8px; margin-top: 8px; }

.stat-strip { display: flex; gap: 28px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.stat-strip div span { display: block; font-size: 12px; color: var(--muted); }
.stat-strip div b { font-size: 20px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

/* Pitch history — each entry reads like a headline on the page. */
.ph { border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; padding: 11px 14px 11px 12px; }
.ph:last-child { border-bottom: 0; }
.ph.st-sent { border-left-color: var(--blue); }
.ph.st-landed { border-left-color: var(--green); }
.ph.st-declined { border-left-color: var(--red); }
.ph.st-no_response { border-left-color: var(--gold); }
.ph.st-withdrawn { border-left-color: var(--faint); }
.ph-top { display: flex; align-items: flex-start; gap: 10px; }
.ph-headline { font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--navy); flex: 1; line-height: 1.35; }
.ph-headline a { color: var(--navy); }
.ph-headline a:hover { color: var(--blue-deep); }
.ph-headline svg { color: var(--faint); }
.ph-acts { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }
.ph-acts .sel-status { max-width: 120px; }
.ph-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.ph-meta b { font-weight: 600; color: var(--text); }
.ph-notes { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; max-width: 70ch; }

.confirm-wrap { display: inline-flex; align-items: center; gap: 5px; }
.confirm-txt { font-size: 11px; font-weight: 700; color: var(--red); }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(13,34,77,.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal { background: var(--card); width: 100%; max-width: 720px; border-top: 3px solid var(--blue); }
.modal-hdr { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--rule); }
.modal-hdr h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; flex: 1; }
.modal-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.modal-x:hover { color: var(--navy); }
.modal-body { padding: 18px 20px 20px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text); }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 11px; color: var(--muted); }

.form-acts { display: flex; align-items: center; gap: 9px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); }
.form-acts .spacer { flex: 1; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hdr { height: auto; flex-wrap: wrap; gap: 8px 20px; padding: 10px 14px; }
  .hdr-brand { order: 1; }
  .hdr-user { order: 2; }
  .hdr::after { content: ""; flex-basis: 100%; height: 0; order: 3; }
  .hdr-nav { order: 4; }
  .tab { padding: 6px 10px 8px; margin-bottom: 0; }
  .tbl-wrap { max-height: none; }
  .main { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 14px; }
  .band-name { font-size: 24px; }
}
@media (max-width: 640px) {
  #user-name { display: none; }
  .band-acts { margin-left: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .btn-toggle, .ibtn, .tab, .subtab, .star { transition: color .12s, background-color .12s, border-color .12s; }
}
