*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --text-muted: #78716c;
  --accent: #2563eb;

  --type-person: #7c3aed;
  --type-organization: #0891b2;
  --type-phonenumber: #16a34a;
  --type-meeting: #d97706;
  --type-emailaddress: #db2777;
  --type-address: #65a30d;
  --type-note: #64748b;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* ── Sidebar ── */

#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

#sidebar-header h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  color: var(--text);
}

#type-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.type-filter {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-muted);
  transition: all 0.1s;
}

.type-filter.active {
  color: #fff;
  border-color: transparent;
}

#object-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.object-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.object-item:hover { background: var(--bg); }
.object-item.active { background: #eff6ff; }

.object-item-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Type badges ── */

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-Person, .type-filter[data-type="Person"].active           { background: var(--type-person); }
.badge-Organization, .type-filter[data-type="Organization"].active { background: var(--type-organization); }
.badge-PhoneNumber, .type-filter[data-type="PhoneNumber"].active  { background: var(--type-phonenumber); }
.badge-Meeting, .type-filter[data-type="Meeting"].active         { background: var(--type-meeting); }
.badge-EmailAddress, .type-filter[data-type="EmailAddress"].active { background: var(--type-emailaddress); }
.badge-Address, .type-filter[data-type="Address"].active         { background: var(--type-address); }
.badge-Note, .type-filter[data-type="Note"].active               { background: var(--type-note); }

/* ── Main / Detail ── */

#main {
  overflow-y: auto;
  padding: 32px;
}

.empty-state {
  color: var(--text-muted);
  margin-top: 80px;
  text-align: center;
}

#detail-view {
  max-width: 640px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.detail-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.fields-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 28px;
}

.field-row {
  display: contents;
}

.field-row > * {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.field-row:last-child > * {
  border-bottom: none;
}

.field-key {
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg);
}

.field-value {
  background: var(--surface);
}

/* ── Relationship cards ── */

.rel-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rel-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.1s, box-shadow 0.1s;
}

.rel-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #2563eb18;
}

.rel-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rel-type-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rel-direction {
  font-size: 11px;
  color: var(--text-muted);
}

.rel-card-name {
  font-weight: 600;
  font-size: 14px;
}

.rel-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.rel-field-chip {
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text-muted);
}

.rel-field-chip span {
  color: var(--text);
  font-weight: 500;
}
