.external-accounts-panel {
  gap: 12px;
}

.external-accounts-section {
  overflow: clip;
  border: 1px solid var(--line, #d8dee3);
  border-radius: 10px;
  background: var(--panel, #fff);
}

.external-accounts-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
}

.external-accounts-section-summary::-webkit-details-marker {
  display: none;
}

.external-accounts-section-summary > span:first-child {
  display: grid;
  gap: 3px;
}

.external-accounts-section-summary strong {
  color: var(--ink, #182026);
  font-size: 16px;
}

.external-accounts-section-summary small,
.external-account-filter-status {
  color: var(--muted, #5d6a73);
}

.external-identity-scopes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.external-identity-scopes .external-account-scope-pills {
  margin-top: 0;
}

.external-accounts-section-toggle {
  color: var(--muted, #5d6a73);
  font-size: 22px;
  line-height: 1;
  transition: transform 120ms ease;
}

.external-accounts-section[open] .external-accounts-section-toggle {
  transform: rotate(180deg);
}

.external-accounts-section-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--line, #d8dee3);
}

.external-account-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 0 4px;
}

.external-account-filters label {
  display: grid;
  gap: 5px;
  min-width: min(220px, 100%);
  color: var(--muted, #5d6a73);
  font-size: 12px;
  font-weight: 700;
}

.external-account-filters select {
  width: 100%;
}

.external-account-filter-status {
  min-height: 20px;
  padding: 4px 0;
  font-size: 12px;
}

.external-account-row[hidden],
[data-external-account-filter-empty][hidden] {
  display: none;
}

.external-accounts-list {
  gap: 0;
}

.external-account-row {
  display: block;
  padding: 0;
}

.external-account-row-summary {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(220px, 1fr) minmax(180px, auto) 28px;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  padding: 12px 4px;
  cursor: pointer;
  list-style: none;
}

.external-account-row-summary::-webkit-details-marker {
  display: none;
}

.external-account-row-toggle {
  color: var(--muted, #5d6a73);
  font-size: 20px;
  transition: transform 120ms ease;
}

.external-account-row[open] .external-account-row-toggle {
  transform: rotate(180deg);
}

.external-account-row-body {
  padding: 0 4px 12px 180px;
}

.external-account-main small {
  color: var(--muted, #5d6a73);
}

.external-account-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.external-slack-workspace-scope-overrides {
  display: grid;
  gap: 8px;
}

.external-slack-workspace-scope {
  border: 1px solid var(--line, #d8dee3);
  border-radius: 8px;
  background: #fff;
}

.external-slack-workspace-scope summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.external-slack-workspace-scope summary small {
  color: var(--muted, #5d6a73);
}

.external-slack-channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

@media (max-width: 560px) {
  .external-accounts-section-summary {
    min-height: 56px;
    padding: 11px 12px;
  }

  .external-accounts-section-body {
    padding: 0 12px 12px;
  }

  .external-account-filters {
    display: grid;
  }

  .external-account-row-summary {
    grid-template-columns: 1fr 28px;
    gap: 8px;
  }

  .external-account-provider,
  .external-account-access {
    grid-column: 1;
  }

  .external-account-row-toggle {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .external-account-access {
    align-items: flex-start;
  }

  .external-account-actions {
    justify-content: flex-start;
  }

  .external-account-row-body {
    padding-left: 4px;
  }
}

/* The reading UI moved to its own page; its styles live in reading.css. */

/* SUBSCRIPTIONS. Same card as its neighbours - it used to render as bare text on the page
   background beneath two proper collapsible cards, which is most of why it read as broken rather
   than merely plain. */
.x-watchlist-section {
  margin-top: 12px;
}
/* The description and the "Subscribe to accounts" button, together. The button used to float hard
   right in a toolbar detached from everything beneath it. */
.x-watchlist-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.x-watchlist-intro p {
  margin: 0;
  flex: 1 1 22rem;
  color: var(--muted, #5d6a73);
}
.x-watchlist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
/* THREE LEVELS, NOT FOUR EQUAL LINES: the name leads, its metadata is demoted under it, the
   accounts and the run status are footnotes. The controls are pulled in beside the name with
   `auto` rather than pinned to the far edge of a full-width row - on a wide screen the eye had to
   cross the whole page to connect a subscription to its buttons. */
.x-watchlist-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  align-items: baseline;
  padding: 12px 14px;
  border: 1px solid var(--line, #d8dee3);
  border-radius: 8px;
  background: var(--panel, #fff);
}
.x-watchlist-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.x-watchlist-name {
  color: var(--ink, #182026);
  font-size: 15px;
}
.x-watchlist-meta {
  font-size: 12.5px;
  color: var(--muted, #5d6a73);
}
.x-watchlist-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-self: end;
}
.x-watchlist-handles,
.x-watchlist-run,
.x-watchlist-cadence,
.x-watchlist-budget {
  grid-column: 1 / -1;
}
/* An account pill now goes to the account. It keeps the pill's shape exactly - inheriting colour
   and dropping the underline - because it should read as the same object it has always been, only
   now obviously clickable on hover. A pill that suddenly wore link-blue would look like a new kind
   of thing rather than the same one gaining an affordance. */
.x-watchlist-handle-pill {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.x-watchlist-handle-pill:hover,
.x-watchlist-handle-pill:focus-visible {
  text-decoration: underline;
  filter: brightness(0.94);
}

/* The shared-cadence line is information, not a warning: being polled MORE often than you asked
   costs the reader nothing, so it must not wear the alarm colour the cap notice does. */
.x-watchlist-cadence {
  font-size: 12.5px;
  color: var(--muted, #5d6a73);
}

/* Suggestions for handles already being collected. Below the field rather than an overlay, so it
   never covers the small print about separators and the 50 cap. */
.x-watchlist-handle-suggest {
  display: grid;
  gap: 6px;
  margin: -6px 0 2px;
}
.x-watchlist-handle-suggest-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted, #5d6a73);
}
.x-watchlist-handle-suggest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.x-watchlist-handle-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.x-watchlist-handle-suggestion small { color: var(--muted, #5d6a73); }
/* "free" is the whole message: an already-collected handle adds no polling at all. */
.x-watchlist-handle-free {
  border: 1px solid var(--line, #d8dee3);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.x-watchlist-run,
.x-watchlist-budget {
  font-size: 12.5px;
}
/* `:not(.external-account-warning)` rather than a bare rule: both are single-class selectors, so
   a plain `.x-watchlist-budget { color: muted }` silently wins over the warning colour and an
   exhausted budget renders exactly as calm as a healthy one. */
.x-watchlist-run:not(.external-account-warning),
.x-watchlist-budget:not(.external-account-warning) {
  color: var(--muted, #5d6a73);
}
/* The budget sits directly under "last checked" because it answers the next question that line
   raises - "so can I check it again now?" - and it must not be mistaken for part of the run
   status above it. */
.x-watchlist-budget {
  display: block;
  margin-top: 2px;
}
.x-watchlist-cadence a {
  font-weight: 700;
}
.source-subscription-panel {
  display: grid;
  gap: 10px;
}
.source-subscription-copy {
  min-width: 0;
  flex: 1 1 28rem;
}
.source-subscription-copy h3,
.source-subscription-copy p {
  margin: 0;
}
.source-subscription-copy h3 {
  font-size: 18px;
}
.source-subscription-copy p {
  margin-top: 4px;
  color: var(--muted, #5d6a73);
}
.source-subscription-channels {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted, #5d6a73);
  font-size: 12.5px;
}
.source-subscription-channels .external-account-scope-pills {
  margin-top: 0;
}
.x-subscription-checks-panel {
  display: grid;
  gap: 14px;
}
.x-subscription-checks-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.x-subscription-checks-summary > div {
  border: 1px solid var(--line, #d8dee3);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
.x-subscription-checks-summary strong {
  display: block;
  font-size: 22px;
}
.x-subscription-checks-summary span,
.x-subscription-checks-subscription small,
.x-subscription-checks-note {
  color: var(--muted, #5d6a73);
  font-size: 12.5px;
}
.x-subscription-checks-list,
.x-subscription-checks-subscriptions {
  display: grid;
  gap: 10px;
}
.x-subscription-checks-subscription {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 170px) minmax(110px, 140px) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line, #d8dee3);
  border-radius: 8px;
}
.x-subscription-checks-subscription--sets-rate {
  border-left: 4px solid #2563eb;
}
.x-subscription-checks-subscription > div,
.x-subscription-checks-subscription label {
  display: grid;
  gap: 4px;
}
.x-subscription-checks-subscription select {
  width: 100%;
}
.x-watchlist-empty-handles {
  font-size: 12.5px;
  color: var(--muted, #5d6a73);
}
@media (max-width: 720px) {
  .x-watchlist-row { grid-template-columns: minmax(0, 1fr); }
  .x-watchlist-row-actions { justify-self: start; }
  .x-subscription-checks-summary,
  .x-subscription-checks-subscription { grid-template-columns: minmax(0, 1fr); }
}

/* The channel picker's own controls. A cached list has to say it is cached, offer the refresh, and
   be searchable - dozens of channels is a scroll, not a list. */
.external-slack-channel-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.external-slack-channel-controls small { color: var(--muted); }
.external-slack-channel-filter {
  flex: 1 1 12rem; min-width: 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.external-slack-channel-empty { color: var(--muted); margin: 6px 0 0; }

/* The controls sit above the identity list on the Connections row itself, not only inside the
   workspace dialog, so they need to survive that row's tighter grid. */
.external-account-row-body > .external-slack-channel-controls { margin: 4px 0 10px; }

/* COLLAPSED BINDING GROUPS. One channel can be a scope's publisher for dozens of scopes; those
   bindings differ only in scope, so they read as one line with the scopes behind a disclosure. */
.external-identity-row > .external-identity-binding-group { grid-column: 1 / -1; }
.external-identity-binding-group { font-size: 13px; color: var(--muted); }
.external-identity-binding-group > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.external-identity-binding-group > summary::-webkit-details-marker { display: none; }
.external-identity-binding-group > summary::after { content: '⌄'; color: var(--muted); font-size: 11px; }
.external-identity-binding-count {
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 11px;
}
.external-identity-binding-group[open] > summary::after { content: '⌃'; }
.external-identity-binding-group .external-account-scope-pills { margin: 6px 0 4px; }
.external-identity-bindings { display: grid; gap: 4px; }
