* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
header { background: #1a1a2e; color: #fff; padding: 20px 0; margin-bottom: 24px; }
header .container { display: flex; justify-content: space-between; align-items: center; }
header h1 { font-size: 1.4em; font-weight: 600; }
.last-checked { font-size: 0.85em; color: #8888aa; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h2 { font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.05em; color: #666; margin-bottom: 12px; }
.card .value { font-size: 2em; font-weight: 700; }
.card .sub { font-size: 0.85em; color: #888; margin-top: 4px; }

.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.status-dot.green { background: #22c55e; }
.status-dot.red { background: #ef4444; }
.status-dot.gray { background: #aaa; }
.status-label { font-size: 1.1em; font-weight: 500; }

.section { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 24px; }
.section h2 { font-size: 1.1em; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
th { text-align: left; padding: 10px 12px; border-bottom: 2px solid #e5e5e5; color: #666; font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
td { padding: 10px 12px; border-bottom: 1px solid #eee; vertical-align: top; }
tr:hover td { background: #fafafa; }

a { color: #3b82f6; text-decoration: none; }
a:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: 500; }
.badge.received { background: #e0f2fe; color: #0c4a6e; }
.badge.create { background: #dcfce7; color: #166534; }
.badge.update { background: #dbeafe; color: #1e40af; }
.badge.skipped { background: #fef3c7; color: #92400e; }
.badge.error { background: #fee2e2; color: #991b1b; }
.badge.note_sync { background: #f3e8ff; color: #6b21a8; }

/* Origin-coded direction. CW = purple, FS = teal; both system
   labels are always colored and the arrow takes the originating
   system's color so the source of an update is obvious at a glance. */
.dir-wrap { font-size: 0.85em; white-space: nowrap; }
.sys { font-weight: 600; }
.sys.cw { color: #7c3aed; }
.sys.fs { color: #0d9488; }
.dir-arrow { margin: 0 4px; font-weight: 700; }
.dir-arrow.from-cw { color: #7c3aed; }
.dir-arrow.from-fs { color: #0d9488; }

/* Explicit timestamp: absolute primary, relative muted secondary */
.time-rel { font-size: 0.8em; color: #999; margin-top: 2px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { padding: 8px 16px; border: none; background: #e5e5e5; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 0.9em; }
.tab.active { background: #fff; font-weight: 600; }

.empty { text-align: center; padding: 40px; color: #999; }

/* Per-column filter row sitting under the table header. */
.filter-row td { padding: 6px 12px; border-bottom: 1px solid #eee; background: #fafafa; }
.filter-input { width: 100%; max-width: 140px; padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.85em; }
.filter-input:focus { outline: none; border-color: #7c3aed; }
.date-filter { display: flex; flex-direction: column; gap: 4px; }
.date-filter label { display: flex; align-items: center; gap: 4px; font-size: 0.75em; color: #888; }
.date-filter label span { width: 28px; }
.date-filter input { flex: 1; padding: 3px 6px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.8em; }
.date-filter input:focus { outline: none; border-color: #7c3aed; }

.btn { display: inline-block; padding: 3px 10px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; color: #374151; font-size: 0.78em; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.sm { padding: 2px 6px; font-size: 0.75em; }

.detail-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85em; color: #666; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 0; font-size: 0.85em; color: #666; }
.pager button { padding: 4px 12px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; cursor: pointer; font-size: 0.85em; }
.pager button:hover { background: #f3f4f6; }
.pager button:disabled { opacity: 0.4; cursor: default; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 100; justify-content: center; align-items: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 8px; width: 92%; max-width: 1100px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 1em; }
.modal-close { background: none; border: none; font-size: 1.4em; cursor: pointer; color: #666; padding: 0 4px; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #eee; display: flex; gap: 8px; justify-content: flex-end; }

.payload-section { margin-bottom: 16px; }
.payload-section h4 { font-size: 0.85em; color: #666; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.payload-content { background: #f8f9fa; border: 1px solid #e5e5e5; border-radius: 4px; padding: 12px; font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; font-size: 0.82em; white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto; line-height: 1.5; }
.payload-empty { color: #999; font-style: italic; }

/* Per-transaction two-column payload layout. Left = originating side,
   right = the outbound request + inbound response it triggered. */
.tx-block { margin-bottom: 24px; border: 1px solid #e5e5e5; border-radius: 6px; overflow: hidden; }
.tx-header { padding: 8px 12px; font-size: 0.85em; font-weight: 600; background: #f1f5f9; color: #475569; border-bottom: 1px solid #e5e5e5; }
.tx-cols { display: grid; grid-template-columns: 1fr 1fr; }
.tx-col { padding: 12px; min-width: 0; }
.tx-col + .tx-col { border-left: 1px solid #eee; }
.tx-col-head { font-size: 0.78em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; padding-bottom: 4px; border-bottom: 2px solid transparent; }
.tx-col-head.origin-cw { color: #7c3aed; border-bottom-color: #7c3aed; }
.tx-col-head.origin-fs { color: #0d9488; border-bottom-color: #0d9488; }
.tx-col-head.neutral { color: #666; border-bottom-color: #d1d5db; }

.copy-btn { padding: 4px 12px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; cursor: pointer; font-size: 0.85em; }
.copy-btn:hover { background: #f3f4f6; }
.copy-btn.copied { background: #dcfce7; border-color: #86efac; }
