* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0 24px 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #222;
  background: #fafbfc;
}
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 0 12px;
  border-bottom: 1px solid #e1e4e8;
  margin-bottom: 16px;
}
.topbar h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
.topbar-meta { display: flex; align-items: center; gap: 12px; }
.last-sync { color: #6a737d; font-size: 0.85rem; }
button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #f6f8fa; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.changed-strip {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 18px;
}
.changed-strip-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6a737d;
  margin-bottom: 6px;
}
.changed-list { list-style: none; margin: 0; padding: 0; }
.changed-list li {
  padding: 4px 0;
  font-size: 0.92rem;
  border-top: 1px solid #f1f3f5;
}
.changed-list li:first-child { border-top: none; }
.changed-list .at { color: #6a737d; margin-right: 10px; font-variant-numeric: tabular-nums; }
.changed-list .empty { color: #999; font-style: italic; }
.filters {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.filters label { display: inline-flex; align-items: center; gap: 6px; }
.filters select, .filters input { padding: 4px 6px; border: 1px solid #d0d7de; border-radius: 4px; font: inherit; }
.filters input { width: 60px; }
.result-count { color: #6a737d; margin-left: auto; }
table.loans {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  overflow: hidden;
}
table.loans th {
  text-align: left;
  padding: 10px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid #e1e4e8;
  font-weight: 600;
  font-size: 0.85rem;
  color: #444;
}
table.loans td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f3f5;
}
table.loans tbody tr { cursor: pointer; }
table.loans tbody tr:hover { background: #f6f8fa; }
table.loans tbody tr:last-child td { border-bottom: none; }
.icon-cell { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.icon-warn { color: #cf222e; }
.icon-active { color: #6a737d; }
.icon-clear { color: #1a7f37; }
.muted { color: #6a737d; padding: 16px; text-align: center; }
.detail-header { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; }
.detail-header h2 { margin: 0; font-size: 1.2rem; }
.badge {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ddf4ff;
  color: #0969da;
  font-weight: 500;
}
.tabs { display: flex; gap: 0; border-bottom: 1px solid #e1e4e8; margin-bottom: 14px; }
.tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  border-radius: 0;
  padding: 10px 14px;
  color: #6a737d;
  font-weight: 500;
}
.tab.active { color: #0969da; border-bottom-color: #0969da; }
.tab-panel { padding: 4px 0; }
.tab-actions { margin-bottom: 12px; }
.tab-actions a {
  font-size: 0.85rem;
  padding: 4px 10px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  text-decoration: none;
  color: #0969da;
  background: #fff;
}
.tab-actions a:hover { background: #f6f8fa; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { padding: 8px 0; border-top: 1px solid #f1f3f5; font-size: 0.92rem; }
.activity-list li:first-child { border-top: none; }
.activity-list .at { color: #6a737d; margin-right: 10px; }
.activity-list .actor { color: #6a737d; font-size: 0.82rem; margin-left: 8px; }
table.bundles { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; }
table.bundles th, table.bundles td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f1f3f5; }
table.bundles th { background: #f6f8fa; font-size: 0.85rem; }
.status-missing { color: #cf222e; }
.status-received { color: #9a6700; }
.status-verified { color: #1a7f37; }
.files-list { list-style: none; padding: 0; margin: 12px 0 0; }
.files-list li { padding: 6px 0; border-top: 1px solid #f1f3f5; font-size: 0.92rem; }
.files-list a { color: #0969da; text-decoration: none; }
.files-list a:hover { text-decoration: underline; }
.placeholder { color: #6a737d; font-style: italic; padding: 12px; background: #f6f8fa; border-radius: 6px; }
.contact-row { display: flex; gap: 14px; padding: 6px 0; }
.contact-row .label { color: #6a737d; min-width: 80px; }

/* Communication tab- thread view + compose mount */
#tab-comms { display: flex; flex-direction: column; gap: 12px; }
.thread-view {
  max-height: 480px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
}
.thread-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.4;
}
.thread-bubble.is-inbound { align-self: flex-start; background: #ddf4ff; color: #1a1a1a; }
.thread-bubble.is-outbound { align-self: flex-end; background: #f1f3f5; color: #1a1a1a; }
.thread-bubble-meta { font-size: 0.72rem; color: #6a737d; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.thread-bubble-body { white-space: pre-wrap; word-wrap: break-word; }
.thread-empty { text-align: center; color: #6a737d; padding: 24px; }
#comms-compose { border-top: 1px solid #e1e4e8; padding-top: 12px; }
