:root {
  --bg: #0a0a0c;
  --surface: #121216;
  --surface-2: #1a1a20;
  --surface-3: #23232a;
  --text: #e8e8ec;
  --text-dim: #9a9aa4;
  --muted: #6b6b74;
  --accent: #2ecc71;
  --accent-dim: rgba(46, 204, 113, 0.12);
  --danger: #e74c3c;
  --border: rgba(255, 255, 255, 0.08);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.55rem 0.75rem;
}

button, select { cursor: pointer; }

button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

button:hover { background: var(--accent); color: var(--bg); }

button.secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--text-dim);
}
button.secondary:hover { border-color: var(--text-dim); color: var(--text); background: transparent; }

button.danger { border-color: var(--danger); background: rgba(231, 76, 60, 0.12); color: var(--danger); }
button.danger:hover { background: var(--danger); color: var(--bg); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

#app { min-height: 100vh; }

/* Auth screens */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  margin-bottom: 1.5rem;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  position: relative;
}
.logo-mark::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.form-field { margin-bottom: 1rem; }
.form-field label {
  display: block;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
}

.error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

.hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 1rem;
  line-height: 1.5;
}

/* App layout */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.user-block {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.user-block .name { color: var(--text); font-weight: 600; }
.user-block .meta { color: var(--muted); font-size: 0.75rem; }

.nav-section h3 {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-list li {
  padding: 0.45rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-list li:hover, .nav-list li.active {
  background: var(--surface-2);
  color: var(--text);
}

.badge {
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 10px;
}

.main {
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.topbar h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tr:hover td { background: var(--surface); cursor: pointer; }

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  color: var(--text-dim);
}
.status-pill.draft { color: var(--text-dim); }
.status-pill.enriching { color: var(--accent); }
.status-pill.review { color: #f1c40f; }
.status-pill.finalized { color: var(--accent); background: var(--accent-dim); }
.status-pill.archived { color: var(--muted); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

pre.code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 3px;
  font-size: 0.75rem;
  overflow-x: auto;
  word-break: break-all;
}

.empty {
  color: var(--muted);
  padding: 2rem 0;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .two-col { grid-template-columns: 1fr; }
}
