:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #17202a;
  --muted: #607086;
  --accent: #1d4ed8;
  --accent-soft: #e8f0ff;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warn: #8a4b00;
  --warn-soft: #fff7e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  min-height: 100vh;
}

.sidebar,
.detail-panel,
.workspace {
  min-width: 0;
}

.sidebar,
.detail-panel {
  background: var(--panel);
  border-color: var(--line);
  border-style: solid;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-width: 0 1px 0 0;
}

.detail-panel {
  padding: 18px;
  border-width: 0 0 0 1px;
  overflow: auto;
}

.brand p,
.eyebrow,
.counts dt,
.node-type,
.edge-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1,
.workspace-header h2,
.detail-panel h2,
.detail-content h3 {
  margin: 4px 0 0;
  line-height: 1.2;
}

.brand h1 {
  font-size: 28px;
}

.controls {
  display: grid;
  gap: 8px;
}

.controls button,
.file-control {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.controls button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.file-control {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.file-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.status {
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
  line-height: 1.35;
}

.status.missing {
  border-color: #f59e0b;
  background: var(--warn-soft);
  color: var(--warn);
}

.status.info {
  border-color: var(--line);
  background: #eef4ff;
  color: #1e3a8a;
}

.status.success {
  border-color: #16a34a;
  background: #ecfdf3;
  color: #166534;
}

.sidebar-section h2,
.edge-panel h2 {
  margin: 0 0 8px;
  font-size: 13px;
}

.drive-section {
  display: grid;
  gap: 8px;
}

.drive-section label {
  display: grid;
  gap: 4px;
}

.drive-section label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.drive-section input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

.drive-section button {
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.drive-section button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.project-list {
  display: grid;
  gap: 6px;
}

.project-button {
  display: grid;
  gap: 3px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.project-button small {
  color: var(--muted);
  font-size: 12px;
}

.project-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #0f3b92;
  font-weight: 700;
}

.tracking-summary {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tracking-filters,
.tracking-list {
  display: grid;
  gap: 6px;
}

.tracking-filters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 8px;
}

.tracking-filter,
.tracking-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.tracking-filter {
  min-height: 30px;
  padding: 5px 6px;
  font-size: 12px;
}

.tracking-filter.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #0f3b92;
  font-weight: 700;
}

.tracking-item {
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 8px;
  text-align: left;
}

.tracking-item strong,
.tracking-item small {
  overflow-wrap: anywhere;
}

.tracking-item small {
  color: var(--muted);
}

.tracking-badge {
  width: max-content;
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf0f5;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-error .tracking-badge {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-review .tracking-badge,
.status-skipped .tracking-badge,
.status-backfill .tracking-badge {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-success .tracking-badge {
  background: #e8f8ee;
  color: #116329;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 14px;
  padding: 18px;
  overflow: auto;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.counts {
  display: flex;
  gap: 8px;
  margin: 0;
}

.counts div {
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.counts dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 700;
}

.graph-panel,
.edge-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.graph-panel {
  padding: 14px;
  overflow: auto;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  min-height: 220px;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  min-height: 220px;
}

.brief-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid #1d4ed8;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.brief-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.brief-card h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.brief-status {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf0f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.brief-metric {
  display: grid;
  gap: 3px;
}

.brief-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.brief-metric strong,
.timeline-row strong,
.timeline-row small,
.project-button small {
  overflow-wrap: anywhere;
}

.node-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.node-column h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.node-card {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.node-card strong,
.node-card small,
.edge-node,
.metadata-list dd {
  overflow-wrap: anywhere;
}

.node-card small {
  color: var(--muted);
}

.node-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.type-project .node-card,
.type-case .node-card {
  border-left-color: #2563eb;
}

.type-thread .node-card {
  border-left-color: #16a34a;
}

.type-mail .node-card {
  border-left-color: #7c3aed;
}

.type-review_bucket .node-card {
  border-left-color: #dc2626;
}

.type-attachment .node-card {
  border-left-color: #d97706;
}

.edge-panel {
  padding: 12px 14px;
}

.edge-list {
  display: grid;
  gap: 7px;
  max-height: 180px;
  overflow: auto;
}

.edge-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 0;
  border-top: 1px solid #edf0f5;
}

.timeline-row {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 54px;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid #edf0f5;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.timeline-row:first-child {
  border-top: 0;
}

.timeline-row span,
.timeline-row small {
  color: var(--muted);
}

.edge-row:first-child {
  border-top: 0;
}

.edge-arrow {
  color: var(--muted);
}

.edge-label {
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf0f5;
}

.detail-panel h2 {
  font-size: 16px;
}

.detail-content {
  margin-top: 12px;
}

.metadata-list {
  display: grid;
  grid-template-columns: minmax(88px, 120px) minmax(0, 1fr);
  gap: 8px 10px;
  margin: 14px 0;
}

.metadata-list dt {
  color: var(--muted);
  font-weight: 700;
}

.metadata-list dd {
  margin: 0;
}

.link-list {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.link-list h4 {
  margin: 0 0 2px;
  font-size: 13px;
}

.link-list a {
  display: block;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-width: 1px 0 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .detail-panel {
    border-width: 0 0 1px;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .graph-grid {
    grid-template-columns: 1fr;
  }
}
