/* Colours and board anatomy follow TaskFlow's Jira-style dark theme. */
:root {
  --bg: #1D2125; --card: #22272B; --pop: #282E33; --sec: #2C333A; --well: #161A1D;
  --fg: #B6C2CF; --fg2: #9FADBC; --muted: #8C9BAB; --dim: #596773; --border: #38414A;
  --primary: #579DFF; --primary-bg: #1C2B41; --red: #F87168; --green: #4BCE97; --amber: #E2B203;
}
* { box-sizing: border-box; border-color: var(--border); }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--primary); text-decoration: none; }
svg { display: block; flex-shrink: 0; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::placeholder { color: var(--dim); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 12px; }
.spacer { flex: 1; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 48px; flex-shrink: 0;
  background: var(--card); border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #fff; white-space: nowrap; }
.logo i { width: 22px; height: 22px; border-radius: 5px; background: var(--primary); color: var(--bg);
  display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 700; font-size: 13px; }
.tabs { display: flex; height: 100%; gap: 4px; }
.tab { padding: 0 12px; height: 100%; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tab:hover { color: var(--fg); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.sys { display: flex; gap: 14px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sys b { color: var(--fg); font-weight: 500; }
.iconbtn { padding: 6px; border-radius: 4px; color: var(--muted); }
.iconbtn:hover { background: var(--pop); color: var(--fg); }

/* secondary bars */
.subbar { display: flex; align-items: center; gap: 8px; padding: 8px 24px; flex-shrink: 0; flex-wrap: wrap;
  background: var(--bg); border-bottom: 1px solid var(--sec); }
.pill { padding: 5px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.pill:hover { background: var(--pop); color: var(--fg); }
.pill.on { background: var(--primary-bg); color: var(--primary); }
.pill .n { margin-left: 6px; font-size: 11px; color: var(--dim); }
.pill .n.bad { color: var(--red); font-weight: 600; }
.sprintbar { display: flex; align-items: center; gap: 10px; padding: 10px 24px; flex-shrink: 0; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border); }
.sprintbar .name { font-weight: 500; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--primary-bg); color: var(--primary); }
.chip.closed { background: var(--sec); color: var(--muted); }
.selectbox { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; color: var(--fg); outline: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.btn-primary { background: var(--primary); color: var(--bg); }
.btn-primary:hover { background: #4C8FEB; }
.btn-ghost { color: var(--fg2); }
.btn-ghost:hover { background: var(--pop); }
.btn-line { border: 1px solid var(--border); color: var(--fg2); }
.btn-line:hover { background: var(--pop); }
.btn-danger { background: #C9372C; color: #fff; }
.btn-danger:hover { background: #AE2E24; }
.btn-sprint { background: rgba(22, 163, 74, .2); color: #4ADE80; border: 1px solid rgba(22, 163, 74, .3); font-size: 12px; font-weight: 600; }
.btn-sprint:hover { background: rgba(22, 163, 74, .3); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.search { position: relative; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.search input { padding: 6px 12px 6px 30px; font-size: 12px; width: 190px; background: var(--card);
  border: 1px solid var(--border); border-radius: 6px; outline: none; }
.search input:focus { border-color: var(--primary); }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow: auto; }

/* project stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) minmax(240px, 1.6fr); gap: 10px; padding: 12px 24px; flex-shrink: 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.stat .label { font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 600; color: #fff; margin: 2px 0; }
.stat .sub { font-size: 12px; color: var(--muted); }
button.stat { text-align: left; font: inherit; }
button.stat:hover { border-color: var(--dim); }
.state-good .value { color: var(--green); } .state-warning .value { color: var(--amber); } .state-critical .value { color: var(--red); }
.stat.state .value { font-size: 16px; line-height: 28px; }
.stat .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 24px 0; flex-shrink: 0; }
.store { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12px; min-width: 0; }
.store b { color: #fff; font-size: 13px; font-weight: 600; }
.store a { margin-left: auto; color: var(--primary); white-space: nowrap; }
.client { font-size: 12px; font-weight: 600; color: var(--muted); padding-right: 8px; }
.banner { padding: 8px 24px; font-size: 13px; color: #fff; background: rgba(226, 178, 3, .18); border-bottom: 1px solid rgba(226, 178, 3, .45); flex-shrink: 0; }
.linkline { padding: 0 0 12px; font-size: 13px; color: var(--muted); }
.linkline a { color: var(--primary); word-break: break-all; }
.statnote { padding: 0 24px 8px; font-size: 12px; color: var(--dim); }
.statnote.stale { color: var(--amber); }
.statsempty { margin: 12px 24px; padding: 14px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); font-size: 13px; }

/* kanban */
.boardwrap { flex: 1; min-height: 0; overflow: auto; }
.board { display: flex; gap: 16px; padding: 4px 24px 24px; min-width: max-content; min-height: 100%; }
.col { width: 288px; flex-shrink: 0; display: flex; flex-direction: column; }
.colhead { display: flex; align-items: center; gap: 8px; padding: 8px 4px; }
.colhead .t { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.colhead .c { font-size: 12px; color: var(--dim); background: var(--pop); border-radius: 999px; padding: 1px 6px; }
.colbody { flex: 1; background: var(--well); border-radius: 8px; padding: 8px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.colbody.over { box-shadow: inset 0 0 0 1px rgba(87, 157, 255, .35); background: #1A2030; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: grab;
  user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.card:hover { background: var(--pop); }
.card .title { font-size: 14px; color: var(--fg); font-weight: 500; word-break: break-word; }
.card .foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.card .key { font-size: 12px; color: var(--dim); }
.card.ghost { opacity: .3; }
.dragover { position: fixed; z-index: 100; pointer-events: none; width: 272px; margin: 0; transform: rotate(2deg);
  border-color: rgba(87, 157, 255, .4); box-shadow: 0 20px 40px rgba(0, 0, 0, .5); opacity: .95; cursor: grabbing; }
.marker { height: 2px; background: var(--primary); border-radius: 2px; margin: -5px 0; }
.addcard { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; font-size: 13px; color: var(--dim); width: 100%; }
.addcard:hover { background: var(--pop); color: var(--fg); }
.tag { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--primary-bg); color: var(--primary); }
.tag.bad { background: rgba(248, 113, 104, .15); color: var(--red); }
.av { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }
.av.none { background: none; border: 1px dashed var(--dim); }
.av.lg { width: 32px; height: 32px; font-size: 11px; }
.pr-CRITICAL { color: #F87168; } .pr-HIGH { color: #FB923C; } .pr-MEDIUM { color: #E2B203; }
.pr-LOW { color: #579DFF; } .pr-LOWEST { color: #8C9BAB; }

/* agents */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 400px) 1fr; }
.agentlist { overflow: auto; border-right: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.agentrow { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.agentrow:hover { background: var(--pop); }
.agentrow.on { border-color: var(--primary); }
.agentrow .top { display: flex; align-items: center; gap: 10px; }
.agentrow .nm { font-weight: 600; color: #fff; }
.agentrow .now { margin-top: 8px; font-size: 12px; color: var(--fg2); }
.agentrow .act { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.status.running::before { background: var(--green); box-shadow: 0 0 0 3px rgba(75, 206, 151, .18); }
.status.running, .status.done { color: var(--green); } .status.done::before { background: var(--green); }
.status.failed, .status.timeout, .status.bad { color: var(--red); }
.status.failed::before, .status.timeout::before, .status.bad::before { background: var(--red); }
.status.queued, .status.scheduled { color: var(--primary); } .status.queued::before, .status.scheduled::before { background: var(--primary); }
.detail { overflow: auto; padding: 20px 24px; min-width: 0; }
.detail h2 { margin: 0; font-size: 18px; color: #fff; font-weight: 600; }
.detail h3 { margin: 22px 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.kv b { color: var(--fg); font-weight: 500; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--sec); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--card); }
.tablewrap { overflow-x: auto; }
.empty { padding: 28px 16px; text-align: center; color: var(--dim); font-size: 13px; }
.section { padding: 16px 24px; }
.zbox { border: 1px solid rgba(248, 113, 104, .5); background: rgba(248, 113, 104, .07); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.zbox .h { color: var(--red); font-weight: 600; margin-bottom: 8px; }
.rowbtns { display: flex; gap: 4px; }
.mini { font-size: 11px; padding: 3px 8px; border-radius: 5px; border: 1px solid var(--border); color: var(--fg2); white-space: nowrap; }
.mini:hover { background: var(--pop); }

/* channel */
.chat { flex: 1; min-height: 0; overflow: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.msg { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; max-width: 900px; }
.msg .h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.msg .h b { color: var(--fg); }
.msg .ru { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--sec); color: var(--fg); }
.compose { display: flex; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--card); flex-shrink: 0; }
.compose textarea { flex: 1; min-height: 38px; height: 38px; resize: vertical; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; outline: none; }
.compose textarea:focus { border-color: var(--primary); }

/* modal & login */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.modal { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); width: 100%; max-width: 640px; padding: 20px; }
.modal.sm { max-width: 420px; }
.modal h2 { margin: 0 0 12px; font-size: 17px; color: #fff; font-weight: 600; word-break: break-word; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.events { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); max-height: 280px; overflow: auto; }
.events .ev b { color: var(--fg); font-weight: 500; }
.logline { font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--sec); word-break: break-word; }
.logline .k { color: var(--dim); margin-right: 6px; }
.resultbox { background: var(--well); border-radius: 6px; padding: 10px 12px; max-height: 320px; overflow: auto; font-size: 13px; }
.errbox { color: var(--red); }
.loginwrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: 100%; max-width: 360px; }
.login .logo { margin-bottom: 20px; font-size: 16px; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--pop); border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.err { color: var(--red); }

@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat.state { grid-column: 1 / -1; } }
@media (max-width: 820px) {
  .split { grid-template-columns: 1fr; grid-auto-rows: min-content; overflow: auto; }
  .agentlist { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .detail { overflow: visible; }
  .sys { display: none; }
  /* The stats eat the phone's height, so the whole page scrolls and the board only scrolls sideways. */
  #view { overflow-y: auto; }
  .boardwrap { flex: none; overflow-y: visible; }
  .board { min-height: 0; }
  .split { flex: none; overflow: visible; }
  .topbar { padding: 0 12px; gap: 8px; }
  .subbar, .sprintbar, .section, .stats, .stores, .banner, .statnote, .compose, .chat { padding-left: 12px; padding-right: 12px; }
  .stores { grid-template-columns: 1fr; }
  .board { padding-left: 12px; padding-right: 12px; }
  .col { width: 260px; }
  .grid2 { grid-template-columns: 1fr; }
}
