/* Settings */
#tab-settings { max-width: 1250px !important; }
#tab-settings > .panel { min-width: 0; scroll-margin-top: calc(var(--bar-h) + 18px); }
.hub-settings-index { display: none; }
@media (min-width: 861px) {
  #tab-settings:not(.hidden) {
    display: grid;
    grid-template-columns: 154px minmax(0, 1fr);
    align-items: start;
    gap: var(--gap-4);
  }
  #tab-settings > .panel { grid-column: 2; }
  .hub-settings-index {
    display: grid;
    align-content: start;
    grid-column: 1;
    grid-row: 1 / span 3;
    position: sticky;
    top: calc(var(--bar-h) + 16px);
    gap: 3px;
    padding: 6px;
    border-radius: var(--r-card);
    background: var(--glass-sidebar);
    box-shadow: var(--rim);
  }
  .hub-settings-index-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    min-height: 40px;
    border-radius: var(--r-ctl);
    color: var(--label-2);
    text-align: start;
  }
  .hub-settings-index-link:hover { color: var(--label); background: var(--fill-hover); }
  .hub-settings-index-link .ico { color: var(--accent-text); }
}
.hub-appearance-body { display: grid; gap: 0; }
.hub-theme-options, .hub-accent-options { min-width: 0; border: 0; padding: 0; margin: 0; }
.hub-theme-options { padding-block-end: var(--gap-4); }
:is(.hub-theme-options, .hub-accent-options) legend { color: var(--label-2); font-size: var(--type-body); font-weight: 600; margin-block-end: 8px; }
.hub-theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.hub-theme-option {
  display: grid;
  position: relative;
  gap: 8px;
  min-width: 0;
  padding: 5px;
  border-radius: var(--r-card);
  box-shadow: var(--rim);
  background: var(--fill);
  cursor: pointer;
  transition: background var(--motion-state) var(--ease), box-shadow var(--motion-state) var(--ease);
}
.hub-theme-option:hover { background: var(--fill-hover); }
.hub-theme-option:has(input:checked) { background: var(--accent-selection); box-shadow: inset 0 0 0 2px var(--accent); }
:is(.hub-theme-option, .hub-accent-option, .hub-preference-switch):has(input:focus-visible) {
  outline: 3.5px solid var(--focus);
  outline-offset: 2px;
}
:is(.hub-theme-option, .hub-accent-option, .hub-preference-switch) input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}
.hub-theme-option .hub-theme-art { aspect-ratio: 1.56; border-radius: calc(var(--r-card) - 5px); box-shadow: inset 0 0 0 1px var(--hair); }
.hub-theme-name { display: block; padding: 0 5px 4px; font-size: var(--type-body); font-weight: 600; }
.hub-theme-check {
  display: none;
  place-items: center;
  position: absolute;
  inset: 9px 9px auto auto;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}
.hub-theme-check .ico { width: 13px; height: 13px; }
.hub-theme-option:has(input:checked) .hub-theme-check { display: grid; }
.hub-theme-mini {
  position: absolute;
  inset: 25% 18% 21%;
  display: grid;
  grid-template: 23% minmax(0, 1fr) / 28% minmax(0, 1fr);
  overflow: hidden;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--label) 29%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 3px 9px color-mix(in srgb, var(--wall-dark) 46%, transparent);
}
.hub-theme-mini-toolbar, .hub-theme-mini-content { display: flex; align-items: center; gap: 3px; padding-inline: 6%; }
.hub-theme-mini-toolbar { grid-column: 1 / -1; border-bottom: 1px solid var(--hair); }
.hub-theme-mini-toolbar > i { width: 4%; aspect-ratio: 1; border-radius: 50%; background: #ff625b; }
.hub-theme-mini-toolbar > i:nth-child(2) { background: #ffc04e; }
.hub-theme-mini-toolbar > i:nth-child(3) { background: #49cd63; }
.hub-theme-mini-sidebar { border-inline-end: 1px solid var(--hair); background: color-mix(in srgb, var(--theme-accent) 15%, transparent); }
.hub-theme-mini-sidebar::after { content: ""; display: block; margin: 28% auto; width: 75%; height: 16%; border-radius: 2px; background: var(--theme-accent); opacity: .55; }
.hub-theme-mini-content { flex-direction: column; justify-content: center; align-items: stretch; gap: 16%; padding-inline: 12%; }
.hub-theme-mini-content > i { background: var(--fill-active); height: 25%; border-radius: 2px; }
.hub-theme-mini-content > i:nth-child(2) { width: 75%; }
.hub-preference-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 56px;
  padding-block: 8px;
  box-shadow: inset 0 -1px var(--hair);
}
.hub-preference-row:last-child { box-shadow: none; }
.hub-preference-label { color: var(--label); font-weight: 600; }
.hub-appearance-body .segmented { max-width: 100%; }
.hub-appearance-body .seg { min-width: 54px; }
.hub-accent-options { padding: 0 0 8px; box-shadow: inset 0 -1px var(--hair); }
.hub-accent-options legend { padding-block-start: var(--gap-3); margin-block-end: 2px; }
.hub-accent-grid { display: flex; flex-wrap: wrap; column-gap: 2px; }
.hub-accent-option {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}
.hub-accent-option:hover { background: var(--fill-hover); }
.hub-accent-option:has(input:checked) .hub-accent-swatch { outline: 2px solid var(--focus); outline-offset: 3px; }
.hub-accent-swatch { width: 25px; height: 25px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .24); }
.hub-preference-switch { position: relative; cursor: pointer; }
.hub-preference-switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--fill-active);
  box-shadow: inset 0 0 0 1px var(--hair-strong);
  transition: background var(--motion-state) var(--ease);
}
.hub-preference-switch-track::before {
  content: "";
  position: absolute;
  inset: 3px auto auto 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--label-2);
  transition: transform var(--motion-state) var(--ease);
}
.hub-preference-switch:has(input:checked) .hub-preference-switch-track { background: var(--accent); }
.hub-preference-switch:has(input:checked) .hub-preference-switch-track::before { transform: translateX(16px); background: var(--accent-ink); }
@media (max-width: 640px) { .hub-theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hub-collection-state {
  display: grid; justify-items: center; align-content: center; gap: 8px; grid-column: 1 / -1;
  min-height: 132px; padding: 20px 16px; color: var(--label-2); text-align: center;
}
.hub-collection-state > .ico { width: 42px; height: 42px; padding: 10px; color: var(--accent-text); background: var(--accent-wash); border-radius: 13px; box-shadow: var(--rim); }
.hub-collection-state[data-status="error"] > .ico { color: var(--red-ink); background: var(--red-wash); }
.hub-collection-state.is-compact > .ico { width: 29px; height: 29px; padding: 6px; border-radius: var(--r-ctl); }
.hub-collection-state p { margin: 0; }
.hub-collection-state[data-status="error"] { color: var(--red-ink); }
.hub-collection-state.is-compact { display: flex; flex-wrap: wrap; justify-content: space-between; min-height: 44px; padding: 8px 12px; text-align: start; border-block-end: 1px solid var(--hair); }
.hub-collection-skeletons { width: min(100%, 420px); display: grid; gap: 8px; margin-top: 4px; }
.hub-collection-skeletons .skeleton { height: 10px; border-radius: var(--r-pill); }
.hub-collection-skeletons .skeleton:nth-child(2) { width: 80%; }
.hub-collection-skeletons .skeleton:nth-child(3) { width: 60%; }

.hub-deals-table:has(tbody:empty) { display: none; }
.hub-deals-table :is(th,td):is(:nth-child(3),:nth-child(4),:nth-child(5),:last-child) { text-align: end; }
.hub-deals-table :is(td,th) { overflow-wrap: anywhere; }
.hub-deals-table td[data-label] > :first-child { min-width: 0; }
.hub-deals-table .chip { white-space: nowrap; }
.hub-group-copy { min-width: 0; overflow-wrap: anywhere; }
.hub-copy-card { min-width: 0; gap: 12px; }
.hub-copy-card .between { flex-wrap: wrap; }
.hub-copy-card .text-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.hub-digest-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hub-digest-stats .stat { min-width: 0; }
#tab-updates .well { min-width: 0; overflow-wrap: anywhere; }
#tab-updates .code { max-width: 100%; overflow-x: auto; }
:is(#tab-digest, #tab-updates) .panel-head .select { max-width: 100%; min-width: 0; }
.hub-request-actions { justify-content: flex-end; padding-top: 10px; border-block-start: 1px solid var(--hair); flex-wrap: wrap; }
.hub-gap-answer { flex: 1 1 275px; min-width: 0; flex-wrap: wrap; }
.hub-gap-answer input { flex: 1 1 140px; min-width: 0; }
.hub-gap-answer button { flex: none; }
.hub-settings-pricing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 12px; border-top: 1px solid var(--hair); }
.hub-setting-save { color: var(--label-2); margin-block-start: 8px; }
.hub-setting-save[data-status="error"] { color: var(--red-ink); }

@media (min-width: 861px) {
  .hub-deals-panel { overflow: clip; overflow-clip-margin: 0; }
  .hub-deals-table th { position: sticky; top: var(--bar-h); z-index: 1; background: var(--glass-menu); }
  .hub-deals-table :is(th,td) { padding-inline: clamp(8px, 1.1vw, 16px); }
}

@media (max-width: 860px) {
  .hub-digest-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .hub-digest-stats .stat:nth-child(3)::before { content: none; }
  .hub-digest-stats .stat:nth-child(n+3) { border-block-start: 1px solid var(--hair); }
  .hub-deals-table td[data-label] { text-align: end; }
  .hub-deals-table td[data-label]::before { text-align: start; flex: none; }
  .hub-deals-table td.t-lead { padding-block-end: 10px; margin-block-end: 4px; border-block-end: 1px solid var(--hair); }
  .hub-deals-table td.t-actions { padding-block-start: 4px; }
}

@media (max-width: 460px) {
  #tab-drafts .segmented, #tab-updates .segmented { max-width: 100%; }
  #tab-drafts .seg, #tab-updates .seg { min-width: 44px; padding-inline: 6px; }
  .hub-settings-pricing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 861px) and (max-width: 1100px) {
  #tab-settings:not(.hidden) { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: start; }
  #tab-settings > .panel { grid-column: 2; }
  .hub-settings-index { grid-column: 1; grid-row: 1 / span 3; }
}

/* Anchored menus and collection history */
.hub-card-floating {
  position: fixed;
  inset: auto;
  z-index: 54;
  margin: 0;
  width: max-content;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  padding: 5px;
  border: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.hub-card-floating[role="menu"] { min-width: 178px; }
.hub-card-menu-trigger > span { font-size: 21px; line-height: .7; letter-spacing: .035em; font-weight: 700; }
.hub-card-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  min-height: 34px;
  border-radius: var(--r-ctl);
  color: var(--label);
  text-align: start;
  white-space: nowrap;
}
.hub-card-menu-item:focus-visible, .hub-card-menu-item:hover:not(:disabled) { background: var(--accent-selection); }
.hub-card-menu-item:disabled { color: var(--label-3); opacity: .62; }
.hub-card-menu-item .ico { color: var(--accent-text); }
@media (pointer: coarse), (hover: none) { .hub-card-menu-item { min-height: 44px; } }

/* Automation controls */
#agents-cards.agent-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: var(--gap-3);
  align-items: stretch;
}
.agent-tile { min-width: 0; }
.agent-tile-inner { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.agent-tile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.agent-tile-icon.squircle { width: 41px; height: 41px; border-radius: 13px; box-shadow: var(--rim); }
.agent-tile-icon .ico { width: 20px; height: 20px; }
.agent-tile-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; }
.agent-tile-name .panel-title { min-width: 0; overflow-wrap: anywhere; }
.agent-tile-description, .agent-tile-summary { overflow-wrap: anywhere; }
.agent-tile-summary { flex: 1; }
.agent-tile-schedule { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.agent-tile-schedule > div { min-width: 0; }
.agent-tile-schedule dt { font-size: var(--type-caption); color: var(--label-3); margin-bottom: 2px; }
.agent-tile-schedule dd { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.agent-tile-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.agent-tile-actions [data-agent-action="toggle"] { margin-inline-start: auto; }
.agent-status.chip-blue { color: var(--blue-ink); background: var(--blue-wash); }
.agent-status { width: fit-content; white-space: nowrap; }
.agent-status .dot { background: currentColor; box-shadow: none; flex: none; }
.agent-status:is([data-run-state="idle"], [data-run-state="paused"]) .dot { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
:root:is([data-motion="full"], [data-motion="subtle"]) .agent-status[data-run-state="running"] .dot { animation: agent-breathe 3s ease-in-out infinite; }
@keyframes agent-breathe { 50% { opacity: .43; box-shadow: 0 0 0 3px var(--blue-wash); } }
.agent-runs-empty { display: none !important; }
.agent-run-row { cursor: pointer; }
.agent-run-disclosure { min-height: 30px; padding: 3px 5px; border-radius: var(--r-ctl); text-align: start; white-space: nowrap; }
.agent-run-disclosure > span { color: var(--accent-text); }
.agent-run-trigger { font-size: var(--type-caption); }
.agent-run-row td { overflow-wrap: anywhere; }
.agent-run-expanded { background: var(--row-hover); }
.agent-run-detail { display: grid; gap: 4px; font-size: var(--type-meta); overflow-wrap: anywhere; }
.agent-history-popover { width: min(385px, calc(100vw - 16px)); max-height: min(580px, calc(100dvh - 16px)); padding: 0; }
.agent-history-inner { padding: 12px; }
.agent-history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-end: 8px; }
.agent-history-list { display: grid; gap: 4px; }
.agent-history-entry { padding: 3px 8px; border-radius: var(--r-ctl); background: var(--fill); }
.agent-history-entry > summary { display: flex; gap: 6px; align-items: center; min-height: 34px; cursor: pointer; }
.agent-history-entry > summary::before { content: '▸'; color: var(--accent-text); }
.agent-history-entry[open] > summary::before { content: '▾'; }
.agent-history-entry > summary::marker { content: ''; }
.agent-history-entry > summary::-webkit-details-marker { display: none; }
.agent-history-entry > summary .agent-status { margin-inline-start: auto; }
.agent-history-entry > :not(summary) { margin: 0 0 8px; overflow-wrap: anywhere; }
.agent-history-entry .agent-run-detail { border-block-start: 1px solid var(--hair); padding-block-start: 8px; }
@media (max-width: 860px) {
  #agents-runs .agent-run-row td { display: flex; min-width: 0; }
  #agents-runs .agent-run-row td::before { flex-shrink: 0; }
  #agents-runs td[data-label="Task"] { flex-wrap: wrap; }
  .agent-tile-actions [data-agent-action="toggle"] { margin-inline-start: 0; }
}
@media (pointer: coarse), (hover: none) {
  .agent-history-entry > summary, .agent-run-disclosure { min-height: 44px; }
}
