/* OFFYCE — cream/ink/accent theme */
:root {
  --cream: #FFF8E7;
  --ink: #1F2937;
  --accent: #6E1423;
  --accent-2: #8E1B2E;
  --gold: #F4D35E;
  --panel: #ffffff;
  --line: #e6dfc8;
  --muted: #8a826f;
  --ok: #2f855a;
  --err: #c53030;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--cream); color: var(--ink);
}
.hidden { display: none !important; }

/* login */
.screen { min-height: 100vh; }
#loginScreen {
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 2.5rem; width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 12px 40px rgba(31,41,55,0.08);
}
.login-card .logo { width: 64px; height: 64px; margin-bottom: .75rem; border-radius: 14px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.login-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.4rem; line-height: 1.5; }
.login-card input, .modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  font-size: .95rem; background: #fff; margin-bottom: .8rem; color: var(--ink);
}
.error { color: var(--err); font-size: .85rem; margin-top: .5rem; min-height: 1em; }

/* app shell */
#appScreen { display: flex; height: 100vh; }
.sidebar {
  width: 240px; background: var(--ink); color: #fff; display: flex; flex-direction: column;
  flex-shrink: 0;
}
.side-head { padding: 1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.side-title { font-weight: 700; font-size: 1rem; }
.side-head { display: flex; justify-content: space-between; align-items: center; }
.agent-list { flex: 1; overflow-y: auto; padding: .5rem; }
.agent-item {
  padding: .6rem .7rem; border-radius: 8px; cursor: pointer; margin-bottom: .25rem;
  border: 1px solid transparent;
}
.agent-item:hover { background: rgba(255,255,255,.07); }
.agent-item.active { background: rgba(244,211,94,.15); border-color: var(--gold); }
.agent-item .a-name { font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; }
.agent-item .a-name .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.agent-item .a-name .dot.exited { background: var(--err); }
.agent-item .a-meta { font-size: .75rem; color: rgba(255,255,255,.55); margin-top: 2px; }
.side-foot { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.12); font-size: .75rem; color: rgba(255,255,255,.5); }
.server-keys { margin-bottom: .5rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; background: var(--line); padding: .35rem .5rem 0; gap: .25rem; overflow-x: auto; }
.tab {
  padding: .45rem 1rem; background: transparent; border: none; cursor: pointer;
  font-size: .85rem; border-radius: 8px 8px 0 0; color: var(--muted); white-space: nowrap;
}
.tab.active { background: var(--cream); color: var(--ink); font-weight: 600; }
.tab .close { margin-left: .5rem; opacity: .5; }
.tab .close:hover { opacity: 1; }
.terminal-area { flex: 1; position: relative; background: #101014; }
.terminal-wrap { position: absolute; inset: 0; padding: .5rem; display: none; }
.terminal-wrap.active { display: block; }
.terminal-wrap .xterm { height: 100%; }
.terminal-toolbar {
  position: absolute; top: .4rem; right: .6rem; z-index: 5; display: flex; gap: .4rem;
}
.terminal-toolbar .btn { font-size: .75rem; padding: .3rem .7rem; }
.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--muted); gap: .6rem; text-align: center;
}
.empty-state h2 { color: var(--ink); }

/* buttons */
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: .6rem 1.2rem;
  font-size: .9rem; font-weight: 600; cursor: pointer; transition: transform .1s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost.invert { color: #fff; border-color: rgba(255,255,255,.4); }
.btn.small { padding: .35rem .7rem; font-size: .8rem; }

/* modal */
.modal {
  position: fixed; inset: 0; background: rgba(15,15,20,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 1.8rem; width: 100%; max-width: 460px;
  max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-card h2 { margin-bottom: 1rem; }
.modal-card label { display: block; font-size: .8rem; font-weight: 600; margin: .6rem 0 .25rem; color: var(--muted); }
.modal-card .check { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); }
.modal-card .check input { width: auto; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ── side nav (Agents / Hive) ── */
.side-head { flex-direction: column; align-items: stretch; gap: .4rem; }
.side-nav-row { display: flex; gap: .4rem; }
.side-nav { flex: 1; }
.side-nav {
  background: transparent; border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.7);
  border-radius: 8px; padding: .45rem .6rem; font-size: .85rem; cursor: pointer; text-align: left;
}
.side-new { width: 100%; background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2); }
.side-new:hover { background: rgba(255,255,255,.18); transform: none; }
.side-nav:hover { color: #fff; }
.side-nav.active { background: rgba(244,211,94,.18); border-color: var(--gold); color: var(--gold); font-weight: 600; }

/* ── hive view ── */
.hive-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--cream); }
.hive-subtabs { display: flex; gap: .35rem; padding: .6rem .8rem; background: var(--line); }
.hive-subtab {
  background: transparent; border: none; border-radius: 8px; padding: .4rem .9rem;
  font-size: .85rem; cursor: pointer; color: var(--muted);
}
.hive-subtab.active { background: var(--accent); color: #fff; font-weight: 600; }
.hive-pane { flex: 1; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .7rem; }

/* kanban */
.kanban-toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.kanban-toolbar input, .kanban-toolbar select {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff;
}
.kanban-toolbar input[type=text] { flex: 1; min-width: 160px; }
.kanban-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; flex: 1; min-height: 0; }
.kanban-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.kanban-col h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: .55rem .7rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.kanban-col h3 .count { float: right; opacity: .6; }
.kb-list { flex: 1; overflow-y: auto; padding: .5rem; display: flex; flex-direction: column; gap: .45rem; }
.kb-card {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: .55rem .65rem; font-size: .85rem;
}
.kb-card .kb-title { font-weight: 600; margin-bottom: .2rem; }
.kb-card .kb-meta { font-size: .75rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.kb-card .kb-actions { display: flex; gap: .3rem; margin-top: .4rem; }
.kb-card .kb-actions button {
  border: 1px solid var(--line); background: var(--cream); border-radius: 6px;
  font-size: .7rem; padding: .15rem .45rem; cursor: pointer; color: var(--ink);
}
.kb-card .kb-actions button:hover { background: var(--gold); }
.kb-card.p1 { border-left-color: #c53030; }
.kb-card.p2 { border-left-color: #dd6b20; }
.kb-card.p4 { border-left-color: #718096; }
.kb-card.p5 { border-left-color: #a0aec0; }

/* messages */
.msg-topbar, .mem-topbar { display: flex; gap: .5rem; align-items: center; }
.msg-topbar select, .mem-topbar select {
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff;
}
.msg-hint { font-size: .78rem; color: var(--muted); }
.msg-layout { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.msg-col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .6rem; min-height: 120px; }
.msg-col h4 { font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.msg-list { display: flex; flex-direction: column; gap: .4rem; max-height: 260px; overflow-y: auto; }
.msg-item {
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; font-size: .82rem; background: #fff;
}
.msg-item .m-head { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.msg-item .m-subj { font-weight: 600; }
.msg-item .m-act { font-size: .68rem; background: var(--cream); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .35rem; color: var(--accent); }
.msg-item .m-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.msg-item .m-body { margin-top: .3rem; white-space: pre-wrap; color: #4a5568; font-size: .8rem; }
.msg-item .m-done {
  margin-top: .35rem; font-size: .7rem; border: none; background: var(--cream);
  border: 1px solid var(--line); border-radius: 6px; padding: .15rem .5rem; cursor: pointer;
}
.msg-item .m-done:hover { background: var(--ok); color: #fff; }
.msg-empty { color: var(--muted); font-size: .8rem; padding: .4rem; }
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .7rem; }
.composer h4 { font-size: .85rem; margin-bottom: .5rem; }
.composer-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.composer input, .composer select, .composer textarea {
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff;
  color: var(--ink);
}
.composer input[type=text] { flex: 1; min-width: 0; }
.composer .composer-row input { flex: 1; }
.composer textarea { width: 100%; margin: .5rem 0; resize: vertical; }

/* memory */
.hive-pane-memory textarea, #hivePane-memory textarea {
  width: 100%; padding: .6rem; border: 1px solid var(--line); border-radius: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem;
  background: #fff; color: var(--ink); resize: vertical;
}
.mem-board-h { margin-top: .8rem; }
#hivePane-memory .btn { align-self: flex-start; }
