/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #22252f;
  --border: #2a2d3a;
  --text: #e1e4ed;
  --text-muted: #8b8fa3;
  --accent: #63e6a0;
  --accent-dim: rgba(99, 230, 160, 0.12);
  --danger: #e66363;
  --danger-dim: rgba(230, 99, 99, 0.12);
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Nav ===== */
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}

.nav-links { display: flex; gap: 12px; }

.nav-link {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-search { margin-left: auto; }
.nav-search input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text);
  font-size: 13px;
  width: 220px;
  outline: none;
}
.nav-search input:focus { border-color: var(--accent); }
.nav-search input::placeholder { color: var(--text-muted); }

/* ===== Layout ===== */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { font-size: 20px; font-weight: 600; }

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-bar input, .filter-bar select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }
.filter-bar input::placeholder { color: var(--text-muted); }
.filter-bar select option { background: var(--surface); }

/* ===== Tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 13px;
}

.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: var(--surface-hover); }

.name-cell { font-weight: 500; }
.date-cell { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--accent-dim);
  color: var(--accent);
}

.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-success { background: var(--accent-dim); color: var(--accent); }

/* ===== Entity Detail ===== */
.entity-header { margin-bottom: 20px; }
.entity-header h1 { font-size: 22px; margin: 8px 0 4px; }

.back-link {
  font-size: 12px;
  color: var(--text-muted);
}

.entity-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-item { color: var(--text-muted); font-size: 13px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-content h2 { font-size: 16px; margin-bottom: 12px; font-weight: 500; }

/* ===== Context ===== */
.context-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 600px;
  overflow-y: auto;
}

/* ===== Draft Cards ===== */
.draft-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.draft-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.entity-link { font-size: 12px; }

.draft-subject {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.draft-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.draft-actions {
  display: flex;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--surface-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-success { border-color: var(--accent); color: var(--accent); }
.btn-success:hover { background: var(--accent-dim); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); }

/* ===== Misc ===== */
.loading { color: var(--text-muted); padding: 24px 0; text-align: center; }
.empty { color: var(--text-muted); padding: 16px 0; text-align: center; font-style: italic; }

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.pagination button {
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.pagination button:hover { background: var(--surface-hover); }
