/* app.css — Team Server v0.2 */
:root {
  --bg: #f7f7f8;
  --fg: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-fg: #fff;
  --ok: #059669;
  --warn: #b45309;
  --err: #dc2626;
  --running: #2563eb;
  --delivered: #059669;
  --closed: #6b7280;
  --assigned: #b45309;
  --rejected: #dc2626;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--fg); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.msg { color: var(--err); min-height: 18px; }
.msg.ok { color: var(--ok); }

button { background: #fff; color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
button:hover { background: #f3f4f6; }
button.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
button.primary:hover { background: #1d4ed8; }
button.link { background: transparent; border: none; color: var(--primary); padding: 0 6px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; font-family: inherit; }
textarea { font-family: ui-monospace, monospace; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* views */
.view { min-height: 100vh; }
#login-view, #register-view { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card input { margin: 8px 0; }
.login-card h1 { font-size: 20px; margin: 0 0 4px 0; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 50px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 600; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tab.active { background: #eff6ff; color: var(--primary); }
.user { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.quota { background: #f3f4f6; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.quota.low { background: #fef3c7; color: var(--warn); }

/* layout */
.tab-pane { padding: 0; }
.two-col { display: grid; grid-template-columns: 360px 1fr; min-height: calc(100vh - 50px); }
.left { border-right: 1px solid var(--border); background: #fff; overflow-y: auto; }
.right { overflow-y: auto; padding: 0; }
.toolbar { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 5; }
.toolbar input, .toolbar select { flex: 1; }
.toolbar button { flex: 0 0 auto; }

/* task list */
.task-list, .exp-list { list-style: none; margin: 0; padding: 0; }
.task-list li, .exp-list li { padding: 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.task-list li:hover, .exp-list li:hover { background: #f9fafb; }
.task-list li.active, .exp-list li.active { background: #eff6ff; border-left: 3px solid var(--primary); padding-left: 9px; }
.task-list .title, .exp-list .title { font-weight: 500; margin-bottom: 4px; }
.task-list .meta, .exp-list .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.status { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.status.draft { background: #f3f4f6; color: var(--muted); }
.status.assigned { background: #fef3c7; color: var(--warn); }
.status.running { background: #dbeafe; color: var(--running); }
.status.delivered { background: #d1fae5; color: var(--delivered); }
.status.closed { background: #f3f4f6; color: var(--closed); }
.status.rejected { background: #fee2e2; color: var(--rejected); }
.status.failed, .status.cancelled { background: #f3f4f6; color: var(--muted); }

/* task detail / process panel */
#task-detail { padding: 20px; }
#task-detail.empty { display: flex; align-items: center; justify-content: center; min-height: 300px; }
.task-card { border: 1px solid var(--border); border-radius: 8px; padding: 16px; background: #fff; margin-bottom: 16px; }
.task-card h2 { margin: 0 0 8px 0; font-size: 18px; }
.task-card .desc { white-space: pre-wrap; color: #4b5563; background: #f9fafb; padding: 12px; border-radius: 6px; margin: 8px 0; font-family: ui-monospace, monospace; font-size: 12px; max-height: 200px; overflow: auto; }
.task-card .meta-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }
.task-card .actions { display: flex; gap: 8px; margin-top: 12px; }

.process-panel { border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.process-panel h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.process-stream { padding: 12px 16px; max-height: 500px; overflow-y: auto; font-size: 13px; }
.event { padding: 6px 0; border-bottom: 1px dashed #f3f4f6; display: flex; gap: 10px; }
.event:last-child { border-bottom: none; }
.event .ts { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; min-width: 80px; flex: 0 0 auto; }
.event .kind { display: inline-block; min-width: 70px; font-weight: 500; }
.event.thinking .kind { color: var(--primary); }
.event.tool_call .kind { color: #7c3aed; }
.event.tool_result .kind { color: #0891b2; }
.event.milestone .kind { color: var(--ok); }
.event.error .kind { color: var(--err); }
.event.info .kind { color: var(--muted); }
.event .title { font-weight: 500; }
.event .detail { color: var(--muted); font-size: 12px; margin-top: 2px; }

.artifact { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px; padding: 8px 12px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }

/* experience detail */
#exp-detail { padding: 20px; }
#exp-detail.empty { display: flex; align-items: center; justify-content: center; min-height: 300px; }
.exp-card { border: 1px solid var(--border); border-radius: 8px; padding: 16px; background: #fff; margin-bottom: 16px; }
.exp-card h2 { margin: 0 0 8px 0; font-size: 18px; }
.exp-body { white-space: pre-wrap; background: #f9fafb; padding: 12px; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 12px; }
.exp-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.exp-tag { background: #eff6ff; color: var(--primary); padding: 1px 8px; border-radius: 4px; font-size: 11px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 8px; padding: 20px; width: 480px; max-width: 90vw; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin: 0 0 12px 0; font-size: 16px; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; margin-bottom: 4px; }
.modal-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* dashboard */
.dash { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-card .num { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card .sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.card-panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-size: 14px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dash-table th { text-align: left; padding: 6px 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.dash-table td { padding: 8px 12px; border-bottom: 1px solid #f3f4f6; }
.dash-table tr:hover td { background: #f9fafb; }
.dash-table .num-cell { font-variant-numeric: tabular-nums; }
.dash-table .u-name { font-weight: 500; }
.dash-logs { max-height: 420px; overflow-y: auto; font-size: 12px; }
.dash-log-item { display: flex; gap: 8px; padding: 5px 14px; border-bottom: 1px solid #f9fafb; }
.dash-log-item .lt { color: var(--muted); font-family: ui-monospace, monospace; flex: 0 0 64px; }
.dash-log-item .lk { color: #7c3aed; font-weight: 500; flex: 0 0 auto; min-width: 90px; }
.dash-log-item .lm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.status-pill.ok { background: #d1fae5; color: var(--ok); }
.status-pill.warn { background: #fef3c7; color: var(--warn); }

/* exp ref link inside desc/body */
.exp-ref-link { color: var(--primary); text-decoration: underline; cursor: pointer; }
