#open-transaction-copilot[hidden],
#transaction-copilot [hidden] {
  display: none;
}

.copilot-tool-row:has(#open-transaction-copilot:not([hidden])) {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

#open-transaction-copilot {
  align-self: flex-start;
  min-width: 0;
  margin: 7px 0 12px;
  color: #123a8c;
}

#open-transaction-copilot span {
  display: inline-block;
  padding: 3px 7px;
  margin-inline-start: 4px;
  border-radius: 6px;
  background: #e8efff;
  color: #123a8c;
  font-size: .75em;
  font-weight: 750;
}

body:has(#transaction-copilot[open]) {
  overflow: hidden;
}

#transaction-copilot {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border: 0;
  background: #f3f6f9;
  color: #162b3a;
  font-family: Inter, system-ui, sans-serif;
}

.copilot-layout {
  display: grid;
  grid-template-columns: clamp(210px, 18.3vw, 280px) minmax(0, 1fr);
  min-height: 100%;
}

.copilot-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 28px 20px;
  background: #0b2145;
  color: #f1f6fc;
}

.copilot-logo {
  display: block;
  width: min(100%, 220px);
  height: auto;
  border-radius: 10px;
}

.copilot-sidebar nav {
  display: grid;
  gap: 8px;
  margin-top: 45px;
}

#transaction-copilot button {
  font: inherit;
  cursor: pointer;
}

#transaction-copilot button:disabled {
  cursor: wait;
  opacity: .65;
}

.copilot-sidebar button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 16px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.copilot-sidebar button:hover,
.copilot-sidebar [aria-current="page"] {
  background: #253959;
}

.copilot-sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgb(255 255 255 / 15%);
}

.copilot-sidebar .copilot-back {
  color: #c1d2ee;
  font-size: .88rem;
}

.copilot-main {
  padding: clamp(24px, 3.35vw, 64px);
  min-width: 0;
}

.copilot-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.copilot-heading,
.copilot-title-group,
.copilot-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.copilot-heading {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 24px;
}

.copilot-title-group {
  flex-wrap: wrap;
  min-width: 0;
}

.copilot-status-pill {
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f7;
  color: #475569;
  white-space: nowrap;
  font-size: .73rem;
  font-weight: 650;
}

.copilot-header-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: min(100%, 520px);
}

#transaction-copilot .copilot-heading .copilot-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.copilot-search {
  position: relative;
  min-width: 0;
}

.copilot-search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
}

.copilot-search-field:focus-within {
  outline: 2px solid #4a7dfa;
  outline-offset: 2px;
}

#transaction-copilot .copilot-search-field input {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 11px 0;
  outline: 0;
  border: 0;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-size: .88rem;
  box-shadow: none;
}

.copilot-search-results {
  position: absolute;
  z-index: 2;
  inset: calc(100% + 6px) 0 auto;
  max-height: min(55dvh, 360px);
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 20px rgb(15 23 42 / 12%);
}

#transaction-copilot .copilot-search-results button {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  color: #0f172a;
  overflow-wrap: anywhere;
}

#transaction-copilot .copilot-search-results button:hover,
#transaction-copilot .copilot-search-results button:focus-visible {
  background: #f1f5f9;
  outline-offset: -2px;
}

.copilot-search-results small,
.copilot-search-results p {
  color: #475569;
  font-size: .82rem;
}

.copilot-search-results p {
  margin: 0;
  padding: 12px;
}

.copilot-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.copilot-metric {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
}

.copilot-metric h2 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0;
  font-size: .82rem;
  font-weight: 650;
}

.copilot-metric[data-tone="attention"] h2::before,
.copilot-metric[data-tone="due"] h2::before {
  content: "";
  flex: 0 0 7px;
  height: 7px;
  border-radius: 50%;
  background: #c45f15;
}

.copilot-metric[data-tone="due"] h2::before {
  background: #2563eb;
}

.copilot-metric strong {
  align-self: center;
  color: #0f172a;
  font-size: clamp(1.12rem, 1.85vw, 1.55rem);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.copilot-metric small {
  color: #475569;
  font-size: .75rem;
}

.copilot-empty {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: clamp(32px, 5vw, 64px) 12px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}

.copilot-empty-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 3px;
  border-radius: 14px;
  background: #eef4ff;
  color: #325ca6;
}

.copilot-empty-icon .copilot-icon {
  width: 23px;
  height: 23px;
}

.copilot-empty h3,
.copilot-empty p {
  margin: 0;
}

.copilot-empty p {
  color: #475569;
}

.copilot-empty button {
  margin-top: 8px;
}

.copilot-heading h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3.05rem);
  letter-spacing: -.04em;
  line-height: 1.14;
  overflow-wrap: anywhere;
}

#transaction-copilot .copilot-primary,
#transaction-copilot .copilot-secondary,
#transaction-copilot .copilot-filter {
  border: 1px solid #cedaea;
  border-radius: 8px;
  padding: 9px 13px;
  background: white;
  color: #163766;
  font-weight: 650;
}

#transaction-copilot .copilot-primary {
  border-color: #123887;
  background: #123887;
  color: white;
  padding: 12px 18px;
}

#transaction-copilot .copilot-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-color: transparent;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: .84rem;
}

#transaction-copilot .copilot-filter[aria-pressed="true"] {
  border-color: #cbd5e1;
  background: #e2e8f0;
  color: #0f172a;
}

.copilot-filter-count,
.copilot-count {
  display: inline-grid;
  min-width: 19px;
  padding: 1px 5px;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: .78em;
  font-weight: 650;
}

.copilot-count {
  padding: 3px 7px;
  background: #f1f5f9;
  font-size: .65em;
  vertical-align: middle;
}

#transaction-copilot .copilot-secondary:hover {
  border-color: #a9bfe5;
  background: #eef4ff;
}

.copilot-panel {
  margin-top: 22px;
  padding: clamp(16px, 1.7vw, 30px);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
}

.copilot-panel h2 {
  margin: 0 0 12px;
}

.copilot-muted {
  color: #536176;
}

.copilot-message {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #e8efff;
}

.copilot-message[data-error="true"] {
  color: #8a221c;
  background: #fee8e5;
}

.copilot-filters,
.copilot-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
}

.copilot-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.copilot-list > li + li {
  border-top: 1px solid #dbe4eb;
}

.copilot-row,
#transaction-copilot .copilot-row-button {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 0;
  overflow-wrap: anywhere;
}

#transaction-copilot .copilot-row-button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
}

#transaction-copilot .copilot-row-button:hover strong {
  text-decoration: underline;
}

.copilot-row strong, .copilot-row-button strong {
  color: #111d2e;
}

.copilot-row small, .copilot-row-button small, .copilot-row time {
  display: block;
  margin-top: 6px;
}

.copilot-row-end {
  flex-shrink: 0;
  text-align: right;
}

.copilot-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  color: #2b514d;
  background: #eaf2ef;
  font-size: .8rem;
  font-weight: 700;
}

.copilot-badge[data-rank="0"] {
  color: #97281d;
  background: #fee5e1;
}

.copilot-badge[data-rank="3"] {
  color: #754700;
  background: #fff0d4;
}

.copilot-fields,
.copilot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.copilot-grid {
  gap: 18px;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.copilot-fields label {
  display: grid;
  gap: 5px;
  font-weight: 600;
}

.copilot-fields :is(input, select, textarea),
.copilot-checklist select {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 9px 11px;
  color: #15283a;
  background: #fff;
  border: 1px solid #bbcadd;
  border-radius: 7px;
  font: inherit;
}

.copilot-wide {
  grid-column: 1 / -1;
}

.copilot-checklist fieldset {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #d6e0ed;
  border-radius: 8px;
}

.copilot-checklist label {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.copilot-checklist input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#transaction-copilot :focus-visible {
  outline: 2px solid #4a7dfa;
  outline-offset: 3px;
}

.copilot-list li:focus {
  scroll-margin-block: 16px;
}

@media (max-width: 1000px) {
  .copilot-grid { grid-template-columns: minmax(0, 1fr); }
  .copilot-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .copilot-layout { display: block; }
  .copilot-sidebar { position: static; min-height: 0; padding: 14px 16px; }
  .copilot-logo { width: min(100%, 132px); }
  .copilot-sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
  .copilot-sidebar nav button { width: auto; padding: 8px; font-size: .89rem; }
  .copilot-sidebar-footer { margin-top: 9px; padding-top: 6px; }
  .copilot-sidebar .copilot-back { width: auto; padding: 7px 8px; }
  #open-transaction-copilot { margin-top: 0; }
}

@media (max-width: 470px) {
  .copilot-fields { grid-template-columns: minmax(0, 1fr); }
  .copilot-main { padding: 18px 14px; }
  .copilot-header-actions { grid-template-columns: 1fr; }
  .copilot-header-actions .copilot-primary { justify-self: start; }
  .copilot-metrics { gap: 8px; }
  .copilot-metric { padding: 11px; }
  .copilot-row-end { max-width: 42%; }
}

.copilot-checklist-items {
  display: grid;
  gap: 6px;
}

.copilot-notes {
  white-space: pre-wrap;
}

#transaction-copilot[data-commission-hidden="true"] [data-commission-visible],
#transaction-copilot:not([data-commission-hidden="true"]) [data-commission-masked] {
  display: none;
}

.copilot-commission-heading,
.copilot-commission-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.copilot-commission-heading {
  align-items: center;
}

.copilot-metric .copilot-commission-heading {
  justify-content: space-between;
}

.copilot-commission-field > div {
  flex: 1;
  min-width: 0;
}

#transaction-copilot .copilot-commission-toggle {
  display: inline-grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475569;
}

#transaction-copilot .copilot-commission-toggle:hover {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #0f172a;
}

.copilot-commission-toggle .copilot-icon {
  width: 16px;
  height: 16px;
}


.copilot-fields .copilot-handled-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copilot-fields .copilot-handled-checkbox input {
  width: auto;
}

.copilot-client-update fieldset {
  display: grid;
  gap: 0.5rem;
  max-height: 16rem;
  overflow: auto;
  min-width: 0;
  border: 1px solid #dbe3ef;
  border-radius: 0.65rem;
  padding: 0.75rem;
}

.copilot-client-update legend {
  font-weight: 600;
}

.copilot-date-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
}

.copilot-date-field:focus-within {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.copilot-date-display[data-empty="true"] {
  color: #64748b;
}

.copilot-date-field input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.copilot-date-field input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  cursor: pointer;
}

.copilot-task-list {
  display: grid;
  gap: 0.875rem;
  margin: 0.875rem 0;
  padding: 0.75rem;
  list-style: none;
  background: #f1f5f9;
  border-radius: 0.75rem;
}

.copilot-task-card {
  min-width: 0;
  padding: 0.875rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-inline-start: 4px solid #10b981;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

.copilot-task-card:hover {
  box-shadow: 0 4px 8px rgb(15 23 42 / 10%);
}

.copilot-task-card:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.copilot-task-card[data-rank="0"] { border-inline-start-color: #dc2626; }
.copilot-task-card[data-rank="3"] { border-inline-start-color: #d97706; }
.copilot-task-card[data-rank="5"] { border-inline-start-color: #94a3b8; }

#transaction-copilot .copilot-task-card > :is(.copilot-row, .copilot-row-button) {
  padding: 0;
}

.copilot-task-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
}

.copilot-task-footer button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}

.copilot-task-footer button svg {
  width: 0.875rem;
  height: 0.875rem;
  flex: none;
}

.copilot-task-start svg { color: #2563eb; }
.copilot-task-wait svg { color: #b45309; }

.copilot-task-footer .copilot-task-start:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.copilot-task-footer .copilot-task-wait:hover {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

.copilot-task-footer .copilot-task-edit {
  margin-inline-start: auto;
  padding-inline: 0.625rem;
  background: rgb(248 250 252 / 80%);
  color: #475569;
}

.copilot-task-footer .copilot-task-edit:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.copilot-task-footer .copilot-task-complete {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.copilot-task-footer .copilot-task-complete:hover {
  border-color: #047857;
  background: #047857;
  color: #fff;
}

.copilot-task-progress {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgb(37 99 235 / 20%);
}

.copilot-task-progress::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: #2563eb;
}

@media (prefers-reduced-motion: reduce) {
  .copilot-task-footer button { transition: none; }
}

.copilot-attention-count {
  background: #fef3c7;
  color: #78350f;
}

.copilot-attention-filters {
  padding-bottom: 1rem;
  border-bottom: 1px solid #f1f5f9;
}

#transaction-copilot .copilot-attention-filters .copilot-filter:not([aria-pressed="true"]):hover {
  background: rgb(226 232 240 / 70%);
}

#transaction-copilot .copilot-attention-filters .copilot-filter[aria-pressed="true"] {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
  box-shadow: 0 1px 2px rgb(15 23 42 / 14%);
}

.copilot-attention-filters [aria-pressed="true"] .copilot-filter-count {
  background: #334155;
  color: #fff;
}

.copilot-attention-list {
  display: grid;
  gap: 0.625rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.copilot-attention-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem clamp(0.5rem, 2vw, 1rem);
  border: 1px solid rgb(226 232 240 / 80%);
  border-inline-start: 4px solid #94a3b8;
  border-radius: 0.75rem;
  background: rgb(248 250 252 / 60%);
  color: #0f172a;
  text-align: start;
  font: inherit;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
}

.copilot-attention-row:hover {
  border-color: #cbd5e1;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

.copilot-attention-row[data-rank="0"] { border-inline-start-color: #dc2626; }
.copilot-attention-row:is([data-rank="1"], [data-rank="2"]) { border-inline-start-color: #10b981; }
.copilot-attention-row[data-rank="3"] { border-inline-start-color: #d97706; }
.copilot-attention-row[data-rank="4"] { border-inline-start-color: #94a3b8; }

.copilot-attention-context {
  overflow-wrap: anywhere;
}

.copilot-attention-address {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.3rem;
  color: #475569;
}

.copilot-attention-address .copilot-icon,
.copilot-attention-chevron {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: #94a3b8;
}

.copilot-attention-row .copilot-row-end small {
  display: block;
  margin-top: 0.25rem;
}

.copilot-set-date {
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 650;
}

.copilot-attention-chevron { transition: transform 150ms; }
.copilot-attention-row:hover .copilot-attention-chevron { transform: translateX(2px); }

@media (prefers-reduced-motion: reduce) {
  .copilot-attention-row, .copilot-attention-chevron { transition: none; }
  .copilot-attention-row:hover .copilot-attention-chevron { transform: none; }
}

.copilot-inline-editor {
  margin-top: 0.75rem;
  padding-top: 0.875rem;
  border-top: 1px solid #e2e8f0;
}

.copilot-inline-editor h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.copilot-quick-date {
  min-height: 0;
  border: 1px solid #fcd34d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.copilot-quick-date:has(input:enabled):hover {
  background: #fde68a;
}

.copilot-quick-date input:disabled {
  cursor: default;
}
