/* Inactive-session cleanup dialog: a quiet utility surface in the existing CTM theme. */
.session-cleanup-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-dim, #8b93a1);
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.session-cleanup-open svg { display: block; width: 18px; height: 18px; }
.session-cleanup-open:hover { color: #d9a45b; background: rgba(217, 164, 91, .12); }
.session-cleanup-open:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 2px; }

dialog.session-cleanup {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  background: var(--bg, #14171d);
  color: var(--fg, #e6e8ec);
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
  overflow: hidden;
}
dialog.session-cleanup[open] { display: flex; flex-direction: column; }
dialog.session-cleanup::backdrop { background: rgba(8, 10, 14, .55); }
/* the dialog is a flex column, which would otherwise beat the hidden attribute */
.session-cleanup [hidden] { display: none !important; }

.session-cleanup-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border, #2a2f3a);
}
.session-cleanup-title { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: .01em; }
.session-cleanup-scope {
  padding: 2px 8px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 999px;
  color: var(--fg-dim, #8b93a1);
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.session-cleanup-icon {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-dim, #8b93a1);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.session-cleanup-icon:hover { color: var(--fg, #e6e8ec); background: rgba(255, 255, 255, .06); }
.session-cleanup-icon:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 2px; }

.session-cleanup-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
}
.session-cleanup-subtitle { margin: 0; color: var(--fg-dim, #8b93a1); font-size: .82rem; }

/* ── WP-2 filter bar ───────────────────────────────────────────────────────────
   One row: a compact 32 px computer select and one 32 px days input.
   Every control in this bar is exactly 32 px tall (AC-2a). */
.session-cleanup-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.session-cleanup-computer {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 240px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  background: var(--bg-card, #202330);
  color: var(--fg, #e6e8ec);
  font: inherit;
  font-size: .82rem;
}
.session-cleanup-computer:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 1px; }

/* One number input owns the age cut (WP-2): "Inactive for [0] days" — 0 is any
   age, n >= 1 is an n-day cut. No preset chips. */
.session-cleanup-days-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 0;
}
.session-cleanup-days-label { color: var(--fg-dim, #8b93a1); font-size: .78rem; white-space: nowrap; }
.session-cleanup-days {
  width: 6ch;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  background: var(--bg-input, rgba(255, 255, 255, .04));
  color: var(--fg, #e6e8ec);
  font: inherit;
  font-size: .8rem;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.session-cleanup-days::-webkit-outer-spin-button,
.session-cleanup-days::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.session-cleanup-days:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 1px; }
.session-cleanup-unit { color: var(--fg-dim, #8b93a1); font-size: .78rem; }
.session-cleanup-age-hint { color: var(--fg-dim, #8b93a1); font-size: .72rem; opacity: .75; white-space: nowrap; }
.session-cleanup-age-hint[hidden] { display: none; }

/* ── One search field, one clear ─────────────────────────────────────────────── */
.session-cleanup-search-row { position: relative; display: flex; align-items: center; min-width: 0; }
.session-cleanup-search-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  background: var(--bg-input, rgba(255, 255, 255, .04));
  color: var(--fg, #e6e8ec);
  font: inherit;
  font-size: .82rem;
}
.session-cleanup-search-input:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 1px; }
/* The one clear control is ours: the native WebKit ✕ is removed, not duplicated. */
.session-cleanup-search-input::-webkit-search-cancel-button,
.session-cleanup-search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.session-cleanup-search-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-dim, #8b93a1);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.session-cleanup-search-clear:hover:not(:disabled) { color: var(--fg, #e6e8ec); background: var(--bg-hover, rgba(255, 255, 255, .06)); }
.session-cleanup-search-clear:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 1px; }
.session-cleanup-search-clear:disabled { opacity: .35; cursor: default; }

/* ── List + its header row (Select all owns the checkbox column) ─────────────── */
.session-cleanup-listwrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  overflow: hidden;
}
.session-cleanup-listwrap:has(.session-cleanup-list:empty) { display: none; }
.session-cleanup-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
}
.session-cleanup-list:empty { display: none; }
.session-cleanup-listhead {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 20px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, #2a2f3a);
  background: var(--bg-card, #202330);
  color: var(--fg-dim, #8b93a1);
  font-size: .74rem;
}
.session-cleanup-row + .session-cleanup-row { border-top: 1px solid var(--border, #2a2f3a); }
.session-cleanup-row-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.session-cleanup-row-main:focus-within { background: rgba(255, 255, 255, .04); }
.session-cleanup-row-select { grid-column: 1; grid-row: 1 / 4; justify-self: start; margin: 0; width: 20px; height: 20px; }
.session-cleanup-row-title { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: .82rem; overflow-wrap: anywhere; }
.session-cleanup-row-cwd { grid-column: 2 / -1; grid-row: 3; color: var(--fg-dim, #8b93a1); font-size: .72rem; overflow-wrap: anywhere; }
.session-cleanup-row-age { grid-column: 3; grid-row: 1; color: var(--fg-dim, #8b93a1); font-size: .72rem; white-space: nowrap; text-align: right; }
.session-cleanup-row-context { grid-column: 2 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; font-size: .75rem; color: var(--fg-dim, #8b93a1); }
.session-cleanup-row-context .machine-chip, .session-cleanup-row-branch { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.session-cleanup-row-context .machine-chip { padding: 1px 6px; border-radius: 4px; background: rgba(187,154,247,.13); color: var(--purple, #bb9af7); }
.session-cleanup-row-icon { display: inline-flex; flex: 0 0 auto; width: 16px; height: 16px; }
.session-cleanup-row-badge { font-variant-numeric: tabular-nums; white-space: nowrap; }
.session-cleanup-row-git { overflow-wrap: anywhere; }

/* ── Copy under the list: one status line, then one dim kept/note line ───────── */
.session-cleanup-message { margin: 0; color: var(--fg-dim, #8b93a1); font-size: .78rem; overflow-wrap: anywhere; }
.session-cleanup-message:empty { display: none; }
.session-cleanup-note { margin: 0; color: var(--fg-dim, #8b93a1); font-size: .74rem; overflow-wrap: anywhere; }
#session-cleanup-protected:empty { display: none; }
#session-cleanup-protected:not(:empty) + .session-cleanup-note-text { margin-left: .35em; }
.session-cleanup-selected { color: var(--fg-dim, #8b93a1); font-size: .74rem; white-space: nowrap; justify-self: end; }
.session-cleanup-count { color: var(--fg-dim, #8b93a1); font-size: .74rem; white-space: nowrap; }
.session-cleanup-count:empty { display: none; }
.session-cleanup-count:not(:empty)::before { content: '· '; }
.session-cleanup-selectall { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-dim, #8b93a1); font-size: .74rem; white-space: nowrap; }
.session-cleanup-summary { margin: 0; color: var(--green, #67c98a); font-size: .82rem; }
.session-cleanup-summary[data-status='warning'] { color: var(--yellow, #e0af68); }
.session-cleanup-detail { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; color: var(--fg-dim, #8b93a1); font-size: .74rem; }
.session-cleanup-detail li { overflow-wrap: anywhere; }

.session-cleanup-foot {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border, #2a2f3a);
  background: rgba(0, 0, 0, .12);
}
.session-cleanup-btn {
  padding: 7px 12px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  background: transparent;
  color: var(--fg, #e6e8ec);
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
}
.session-cleanup-btn:hover:not(:disabled) { border-color: var(--fg-dim, #8b93a1); }
.session-cleanup-btn:focus-visible { outline: 2px solid var(--accent, #4c8dff); outline-offset: 2px; }
.session-cleanup-btn:disabled { opacity: .45; cursor: default; }
.session-cleanup-primary { border-color: rgba(217, 164, 91, .55); color: #d9a45b; }
.session-cleanup-primary:hover:not(:disabled) { background: rgba(217, 164, 91, .12); }
.session-cleanup-btn:disabled.session-cleanup-primary { border-color: var(--border, #2a2f3a); color: var(--fg-dim, #8b93a1); }

.session-cleanup-scope { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.session-cleanup-head { flex-wrap: wrap; }
.session-cleanup-fleet-status { margin: 0; color: var(--fg-dim, #8b93a1); overflow-wrap: anywhere; }
.session-cleanup-fleet-status:empty { display: none; }

@media (max-width: 480px) {
  .session-cleanup-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .session-cleanup-title { grid-column: 1; grid-row: 1; }
  .session-cleanup-scope { grid-column: 1; grid-row: 2; width: max-content; }
  .session-cleanup-icon { grid-column: 2; grid-row: 1 / 3; }
  .session-cleanup-body { gap: 12px; padding: 16px; }
  /* The filter bar wraps to two lines: computer, then the days input; still no
     horizontal scroll (AC-2a). */
  .session-cleanup-computer { flex: 1 1 100%; max-width: none; }
  .session-cleanup-days-group { flex: 1 1 100%; }
  .session-cleanup-list { flex-shrink: 0; }
  .session-cleanup-row-main { grid-template-columns: auto minmax(0, 1fr); }
  .session-cleanup-row-cwd { grid-column: 2 / 3; white-space: normal; overflow-wrap: anywhere; }
  .session-cleanup-row-age { grid-column: 1 / -1; grid-row: 4; text-align: left; }
  .session-cleanup-row-select { grid-row: 1; align-self: start; }
  .session-cleanup-foot { justify-content: stretch; }
  .session-cleanup-foot .session-cleanup-btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .session-cleanup-scope { width: auto; }
}
