:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e3e5ea;
  --text: #1d2026;
  --muted: #6b7280;
  --accent: #2f6feb;
  --inactive: #b9bdc4;
  --shadow: 0 1px 2px rgba(15, 22, 37, 0.06), 0 4px 12px rgba(15, 22, 37, 0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover {
  background: #eef0f4;
  color: var(--text);
}

.tab.is-active {
  background: #eef2ff;
  color: var(--accent);
  border-color: #d9e1ff;
}

.view {
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.view[hidden] {
  display: none;
}

.view.directory {
  overflow: auto;
  padding: 12px 12px 28px;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 720px) {
  .view.directory { padding: 16px 20px 28px; }
}

.directory table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.directory thead th {
  text-align: left;
  background: #f3f4f7;
  color: var(--text);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.directory thead th .sort-arrow {
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}

.directory tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.directory tbody tr:last-child td { border-bottom: none; }

.directory tbody tr:hover { background: #f9fafc; }

.directory tbody tr.inactive td {
  color: var(--muted);
  background: #fafafa;
}

.directory .row-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #cdd5e0, #a4b1c2);
  background-size: cover;
  background-position: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.directory .name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.directory .name-cell strong { font-weight: 600; }

.directory .row-areas { display: flex; flex-wrap: wrap; gap: 4px; }

.directory td a {
  color: var(--accent);
  text-decoration: none;
}

.directory td a:hover { text-decoration: underline; }

.directory tr.no-match td { color: var(--muted); text-align: center; padding: 24px; }

.directory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.directory-filters label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  gap: 4px;
}

.directory-filters select {
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 0;
  width: 100%;
}

@media (min-width: 480px) {
  .directory-filters select { min-width: 160px; width: auto; }
}

.directory-filters label {
  flex: 1 1 140px;
}

@media (min-width: 480px) {
  .directory-filters label { flex: 0 0 auto; }
}

.directory-filters select:focus {
  outline: none;
  border-color: var(--accent);
}

.directory-filters .reset-filters {
  font: inherit;
  font-size: 13px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

.directory-filters .reset-filters:hover {
  background: var(--bg);
  color: var(--text);
}

.directory .status-pill {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid transparent;
  line-height: 1.5;
}

.directory .status-active {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.directory .status-inactive {
  background: #f3f4f7;
  color: var(--muted);
  border-color: var(--border);
}

.status {
  font-size: 13px;
  color: var(--muted);
  flex-basis: 100%;
  margin-top: -2px;
}

@media (min-width: 720px) {
  .status {
    flex-basis: auto;
    margin-top: 0;
  }
}

#chart {
  flex: 1;
  width: 100%;
  overflow: hidden;
}

.node-card {
  width: 230px;
  height: 100px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.node-card.inactive {
  background: #f5f5f7;
  color: var(--muted);
  border-style: dashed;
}

.node-card .photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #cdd5e0, #a4b1c2);
  color: white;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.node-card .meta {
  min-width: 0;
  flex: 1;
}

.node-card .name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-card .title {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-card .chips {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.area {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.5;
}

.node-card.inactive .area,
.directory tr.inactive .area {
  background: #ececef !important;
  color: var(--muted) !important;
  border-color: transparent !important;
}

.node-card .badge {
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #ffe4e4;
  color: #b42318;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.node-card.synthetic {
  background: #1d2026;
  border-color: #1d2026;
  color: #fff;
  height: 64px;
  width: 230px;
  justify-content: center;
}

.node-card.synthetic .name {
  color: #fff;
  font-size: 14px;
}


