:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4493f8;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button:hover { filter: brightness(1.1); }
input, select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px;
}

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 40px; width: 340px; text-align: center;
}
.login-card h1 { letter-spacing: 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; min-height: 16px; }
.hint.err { color: var(--red); }
.hint.ok { color: var(--green); }

/* layout */
header {
  display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: 3px; }
.brand-sub { color: var(--muted); font-weight: 400; letter-spacing: 0; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button {
  background: transparent; color: var(--muted); font-weight: 500;
  padding: 6px 12px; border-radius: 6px;
}
nav button.active { background: var(--panel-2); color: var(--text); }
.me { color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; }
main { padding: 24px; max-width: 1200px; margin: 0 auto; }
h2 { font-size: 16px; margin: 18px 0 12px; }

/* stats */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; min-width: 150px;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; }

/* feed */
.feed { display: flex; flex-direction: column; gap: 6px; }
.feed-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; display: flex; gap: 12px; align-items: baseline;
}
.feed-item .when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.feed-item .who { color: var(--accent); font-size: 12px; white-space: nowrap; }
.badge {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.spend { color: var(--amber); }
.badge.error { color: var(--red); }
.badge.decision { color: var(--green); }

/* org tree */
.org-node { margin-left: 22px; border-left: 1px solid var(--border); padding: 4px 0 4px 14px; }
.org-node.root { margin-left: 0; border-left: 0; padding-left: 0; }
.org-card {
  display: inline-flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; margin: 2px 0;
}
.org-card:hover { border-color: var(--accent); }
.org-card .lvl {
  font-size: 10px; text-transform: uppercase; padding: 2px 6px; border-radius: 4px;
  background: var(--panel-2); color: var(--muted);
}
.org-card .lvl.board { color: #d2a8ff; }
.org-card .lvl.c_suite { color: var(--accent); }
.org-card .lvl.vp { color: var(--green); }
.org-card .lvl.director { color: var(--amber); }
.org-card .agents-chip { font-size: 11px; color: var(--muted); }

/* grid / cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card h3 { font-size: 14px; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.idle { background: var(--muted); }
.status-dot.active { background: var(--green); }
.status-dot.paused { background: var(--amber); }
.status-dot.retired { background: var(--red); }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

/* conversations */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.conv-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.conv-item { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.conv-item:hover, .conv-item.sel { border-color: var(--accent); }
.conv-detail { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-height: 70vh; overflow-y: auto; }
.msg { margin-bottom: 14px; }
.msg .role { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.msg .content { white-space: pre-wrap; margin-top: 2px; }
.msg .thinking {
  margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--amber);
  background: var(--panel-2); border-radius: 0 6px 6px 0;
  color: var(--muted); font-size: 12px; white-space: pre-wrap;
}
.msg .thinking summary, details.think summary { cursor: pointer; color: var(--amber); font-size: 11px; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; }
.drawer-inner {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 95vw);
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 24px; overflow-y: auto;
}
.drawer-inner .close { position: absolute; top: 12px; right: 12px; }
.drawer-inner h3 { margin-bottom: 4px; }
.drawer-inner .dept { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.drawer-inner h4 { margin: 16px 0 6px; font-size: 13px; color: var(--accent); }
.drawer-inner ul { margin-left: 18px; color: var(--text); }
.drawer-inner li { margin-bottom: 3px; font-size: 13px; }
.kv { display: flex; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.kv .k { color: var(--muted); min-width: 130px; }
code.key { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; font-size: 11px; word-break: break-all; }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters { margin-bottom: 12px; }

/* ---------- Anahi.ai assistant ---------- */
.anahi-launch {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(160deg, #6f4bd8, #4493f8);
  color: #fff; border: 0; border-radius: 0 12px 12px 0;
  padding: 14px 8px; cursor: pointer; z-index: 90;
  box-shadow: 2px 0 14px rgba(0,0,0,.4); font-weight: 600;
}
.anahi-launch:hover { filter: brightness(1.08); }
.anahi-launch-label { font-size: 11px; writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: 1px; }
.anahi-spark { color: #d2a8ff; }
.anahi-launch .anahi-spark { color: #fff; font-size: 16px; }

.anahi-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 95; }

.anahi-panel {
  position: fixed; left: 0; top: 0; bottom: 0; width: min(400px, 92vw);
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 96;
  transform: translateX(-102%); transition: transform .25s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,.4);
}
.anahi-panel.open { transform: translateX(0); }

.anahi-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(120deg, rgba(111,75,216,.18), rgba(68,147,248,.10));
}
.anahi-title { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.anahi-title .anahi-tld { color: var(--muted); font-weight: 500; }
.anahi-icon {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; width: 32px; height: 32px; padding: 0; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.anahi-icon:hover { color: var(--text); }
.anahi-icon.send { background: var(--accent); color: #fff; border-color: transparent; }

.anahi-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.anahi-empty { color: var(--muted); font-size: 13px; }
.anahi-suggests { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.anahi-suggest {
  text-align: left; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  font-weight: 500; font-size: 12.5px; cursor: pointer;
}
.anahi-suggest:hover { border-color: var(--accent); }

.anahi-msg { max-width: 92%; font-size: 13px; line-height: 1.5; }
.anahi-msg.user {
  align-self: flex-end; background: var(--accent); color: #fff;
  border-radius: 12px 12px 2px 12px; padding: 9px 12px; white-space: pre-wrap;
}
.anahi-msg.assistant {
  align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px; padding: 9px 12px; white-space: pre-wrap;
}
.anahi-msg.assistant.pending { color: var(--muted); font-style: italic; }
.anahi-directive {
  align-self: flex-start; font-size: 11px; color: var(--green);
  border: 1px dashed var(--green); border-radius: 8px; padding: 6px 10px; background: rgba(63,185,80,.06);
}
.anahi-err { align-self: flex-start; color: var(--red); font-size: 12px; }

.anahi-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.anahi-composer textarea {
  flex: 1; resize: none; max-height: 140px; font: inherit; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 11px; line-height: 1.4;
}
.anahi-composer textarea:focus { outline: none; border-color: var(--accent); }

@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; }
  main { padding: 14px; }
}

/* people assigned to a position */
.people-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.people-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px;
}
.people-list .person { font-weight: 600; }
button.tiny { padding: 3px 8px; font-size: 11px; }
.assign-form { display: flex; gap: 8px; margin-top: 10px; }
.assign-form select { flex: 1 1 auto; min-width: 0; }
.assign-form input { flex: 1 1 auto; min-width: 0; }
