:root {
  --bg: #0d0f14; --bg2: #141821; --bg3: #1b2030; --line: #262c3d; --line2: #333b52;
  --text: #e6e9f2; --dim: #9aa3b8; --faint: #6b7489;
  --accent: #7c6cff; --accent2: #a597ff; --good: #3ecf8e; --warn: #f5b84a; --bad: #ff6b6b; --info: #4cc2ff;
  --leader: #ffb84d; --worker: #4cc2ff; --human: #3ecf8e;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--bg3); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #242a3d; border-color: #46506d; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #6a59ff; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--bg3); }
button.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 10px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 4px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
.muted { color: var(--dim); } .faint { color: var(--faint); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* top bar */
header.top { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 20; }
.logo { font-weight: 800; letter-spacing: .5px; font-size: 17px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.logo .dot { width: 18px; height: 18px; border-radius: 6px; background: conic-gradient(var(--accent), var(--info), var(--good), var(--leader), var(--accent)); }
.crumb { color: var(--dim); }
.crumb b { color: var(--text); }
.menu { position: relative; }
.menu .pop { position: absolute; right: 0; top: 38px; background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius); min-width: 200px; padding: 6px; box-shadow: 0 12px 40px #0008; }
.menu .pop button { display: block; width: 100%; text-align: left; border: 0; background: transparent; }
.menu .pop button:hover { background: var(--bg3); }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* login */
.login { max-width: 360px; margin: 12vh auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.click:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg3); color: var(--dim); border: 1px solid var(--line2); white-space: nowrap; }
.pill.leader { color: var(--leader); border-color: #5a4320; background: #2a2114; }
.pill.worker { color: var(--worker); border-color: #1e4a63; background: #10222d; }
.pill.human { color: var(--human); border-color: #1c4d39; background: #10251c; }
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); } .pill.warn { color: var(--warn); }
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.sdot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }
.sdot.paused { background: var(--warn); }
h2 { font-size: 18px; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-weight: 500; font-size: 12px; }

/* project layout */
.project { display: grid; grid-template-columns: 270px minmax(0, 1fr) 340px; height: calc(100vh - 52px); }
.side { border-right: 1px solid var(--line); background: var(--bg2); overflow: auto; padding: 14px; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.side h4 { margin: 14px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--faint); display: flex; align-items: center; }
.side h4:first-child { margin-top: 0; }
.member { padding: 8px; border-radius: 9px; border: 1px solid transparent; margin-bottom: 4px; cursor: default; }
.member:hover { background: var(--bg3); border-color: var(--line2); }
.member .name { font-weight: 600; }
.member .act { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; font-family: var(--mono); }
.member .tools { display: none; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.member:hover .tools { display: flex; }
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); background: var(--bg); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 8px 12px; color: var(--dim); white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: var(--bg3); border-radius: 99px; padding: 0 6px; margin-left: 4px; color: var(--dim); }
.pane { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; }
.pane.flex { display: flex; flex-direction: column; padding: 0; }

/* chat */
.feed { flex: 1; overflow: auto; padding: 14px 16px; }
.msg { display: flex; gap: 10px; margin-bottom: 12px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; color: #0d0f14; }
.msg .body { min-width: 0; }
.msg .who { font-weight: 600; font-size: 13px; }
.msg .who .t { color: var(--faint); font-weight: 400; font-size: 11px; margin-left: 6px; }
.msg .txt { white-space: pre-wrap; word-break: break-word; }
.msg.dm .txt { border-left: 2px solid var(--accent); padding-left: 8px; }
.sys { font-size: 12px; color: var(--faint); margin: 4px 0 10px 40px; display: flex; gap: 6px; align-items: baseline; }
.sys .ico { width: 14px; text-align: center; }
.sys.task { color: #b9b2ff; } .sys.cmd { color: #86c6e8; font-family: var(--mono); } .sys.file { color: #8fd8b5; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; background: var(--bg2); }
.composer select { width: 160px; flex: none; }
.composer textarea { min-height: 40px; max-height: 160px; }

/* board */
.board { display: grid; grid-template-columns: repeat(6, minmax(180px, 1fr)); gap: 10px; min-width: 1100px; height: 100%; }
.col { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.col.over { border-color: var(--accent); }
.col h5 { margin: 0; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.col .items { padding: 8px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tcard { background: var(--bg3); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 10px; cursor: grab; }
.tcard:hover { border-color: #4b5576; }
.tcard .tt { font-weight: 600; font-size: 13px; }
.tcard .meta { font-size: 11px; color: var(--dim); margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tcard .res { font-size: 12px; color: var(--dim); margin-top: 6px; border-top: 1px dashed var(--line2); padding-top: 6px; white-space: pre-wrap; }

/* map */
.mapwrap { position: relative; width: 100%; height: 100%; min-height: 300px; }
.mapwrap svg { width: 100%; height: 100%; display: block; }
.mapwrap .legend { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--faint); display: flex; gap: 10px; flex-wrap: wrap; }
.node-label { font-size: 12px; font-weight: 600; fill: var(--text); }
.node-sub { font-size: 10px; fill: var(--dim); }
.node-act { font-size: 10px; fill: var(--faint); font-family: var(--mono); }

/* activity / terminal */
.ev { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 13px; }
.ev .h { display: flex; gap: 8px; align-items: baseline; }
.ev .h .t { color: var(--faint); font-size: 11px; font-family: var(--mono); }
.ev pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 6px; max-height: 260px; overflow: auto; color: #c8cede; }
.term { background: #07080b; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-family: var(--mono); font-size: 12.5px; min-height: 300px; max-height: calc(100vh - 230px); overflow: auto; white-space: pre-wrap; word-break: break-word; }
.term .cmd { color: var(--good); }
.files { display: grid; grid-template-columns: 280px 1fr; gap: 12px; height: 100%; }
.files .list { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.files .list div { padding: 4px 10px; font-family: var(--mono); font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files .list div:hover, .files .list div.on { background: var(--bg3); }
.files .view { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #07080b; padding: 10px; }

/* right column */
.stat { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat > div { background: var(--bg3); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--dim); }
.progress { height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width .4s; }
.minimap { height: 300px; border: 1px solid var(--line); border-radius: 12px; background: radial-gradient(circle at 50% 45%, #1a1f33, var(--bg) 70%); overflow: hidden; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; padding: 20px; width: min(620px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px #000c; }
.modal h3 { margin: 0 0 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.copybox { position: relative; background: #07080b; border: 1px solid var(--line2); border-radius: 8px; padding: 10px 70px 10px 10px; font-family: var(--mono); font-size: 12px; word-break: break-all; margin-top: 4px; }
.copybox button { position: absolute; right: 6px; top: 6px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line2); padding: 8px 14px; border-radius: 10px; z-index: 60; box-shadow: 0 10px 30px #0008; }
.toggle { display: flex; gap: 8px; align-items: center; margin: 10px 0; cursor: pointer; }
.toggle input { width: auto; }
.empty { text-align: center; color: var(--faint); padding: 40px 10px; }

@media (max-width: 1100px) {
  .project { grid-template-columns: 230px minmax(0, 1fr); }
  .side.right { display: none; }
}
@media (max-width: 760px) {
  .project { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 260px; }
  .center { height: calc(100vh - 52px); }
  main { padding: 14px 16px; }
  header.top { padding: 0 12px; }
  .crumb { display: none; }
}
