/* agent-notify 面板
 *
 * 设计：仪表盘，不是网页。扎根在这些 agent 真正运行的地方——终端。
 * 「需要你」独占顶区、计时为全页最大字号；其余会话降为行式台账。
 * 不对称即设计：余光扫过去，只有真正等你的东西是亮的。
 *
 * 字体一律用系统栈：自托管单二进制不该为字面好看引入外部请求或几百 KB 内嵌。
 * 性格来自布局、密度、等宽数字与克制的用色，不来自字体本身。
 */

:root {
  --ground: #0D1014;
  --surface: #151A20;
  --raised: #1A2027;
  --sunken: #0A0D11;
  --line: #232A33;
  --line-soft: #1B2128;
  --ink: #DCE3EC;
  --dim: #8A94A1;
  --faint: #616B78;

  /* 语义色与主题色分开：等确认用琥珀而非红——红留给真正的故障，
     一块常年开着的面板满屏红色两天就脱敏了 */
  --wait: #F0A030;
  --wait-wash: rgb(240 160 48 / .09);
  --wait-edge: rgb(240 160 48 / .32);
  --run: #57A8E0;
  --done: #5A9E78;
  --danger: #E5695B;

  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #F1F3F6;
    --surface: #FFFFFF;
    --raised: #F7F9FB;
    --sunken: #F0F2F5;
    --line: #DEE3E9;
    --line-soft: #E9ECF1;
    --ink: #161A20;
    --dim: #5C6673;
    --faint: #8792A0;

    --wait: #B45309;
    --wait-wash: rgb(180 83 9 / .06);
    --wait-edge: rgb(180 83 9 / .28);
    --run: #1D4ED8;
    --done: #15803D;
    --danger: #C0392B;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 5px;
  padding: 4px 11px;
  transition: border-color .12s, color .12s, background .12s;
}
button:hover { border-color: var(--dim); }
button:focus-visible { outline: 2px solid var(--run); outline-offset: 1px; }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--ground); font-weight: 600; }
button.primary:hover { opacity: .88; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }

input {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--ground);
  color: var(--ink);
}
input:focus { outline: 2px solid var(--run); outline-offset: -1px; border-color: transparent; }
input::placeholder { color: var(--faint); }

code, pre { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--dim); font-size: 13px; }

/* ── 顶栏 ───────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: .02em; color: var(--ink);
}
.topbar nav { display: flex; gap: 2px; flex: 1; margin-left: 6px; }
.topbar nav a {
  font-size: 13px; color: var(--dim); text-decoration: none;
  padding: 4px 11px; border-radius: 5px;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active { color: var(--ink); background: var(--raised); }
.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.conn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.conn.on { color: var(--dim); }
.conn.on::before { background: var(--done); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px; color: var(--faint); background: transparent; border-color: transparent;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line); background: var(--raised); }

/* ── 全屏：挂副屏/墙上看的状态，收起导航、放大远看要紧的字 ── */

body.fs .topbar nav,
body.fs .userbox { display: none; }
body.fs .topbar { height: 40px; }
body.fs main { max-width: none; padding: 24px 32px 40px; }
body.fs .calls { grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); gap: 12px; }
body.fs .call { padding: 18px 20px 18px 22px; column-gap: 24px; grid-template-columns: 140px minmax(0, 1fr) auto; }
body.fs .call-timer .t { font-size: 54px; }
body.fs .call-proj { font-size: 22px; }
body.fs .call-org { font-size: 14px; }
body.fs .call-msg { font-size: 17px; }
body.fs .zone-head { font-size: 12px; padding-bottom: 11px; }
body.fs .lrow { padding: 14px 14px 14px 17px; }
body.fs .lst .s { font-size: 11.5px; }
body.fs .lst .w { font-size: 13px; }
body.fs .lid .p { font-size: 15px; }
body.fs .lid .o { font-size: 12.5px; }
body.fs .lmsg .m { font-size: 15px; }
body.fs .lmsg .e { font-size: 11.5px; }
body.fs .lmeta { font-size: 12.5px; }
body.fs .log { font-size: 13px; }
body.fs .log .m { font-size: 13.5px; }

main { max-width: 1560px; margin: 0 auto; padding: 22px 20px 60px; }
.empty { color: var(--dim); text-align: center; padding: 72px 20px; line-height: 1.9; }
.empty a { color: var(--run); }

/* ── 分区标题 ────────────────────────────────────── */

.zone + .zone { margin-top: 30px; }
.zone-head {
  display: flex; align-items: center; gap: 11px;
  padding-bottom: 9px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
}
.zone-n { font-weight: 600; color: var(--dim); }
.zone-head.call-zone .zone-n { color: var(--wait); }
.zone-rule { flex: 1; height: 1px; background: var(--line); }

/* ── 需要你：顶区大计时 ──────────────────────────── */

/* 按宽度自动分列：区块内容只有 ~450px，独占整行是浪费。
   用 auto-fill 而非 auto-fit——只剩一个等确认时保持固定宽度，
   而不是把 450px 的内容抻成 1500px。 */
.calls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 10px;
  align-items: start;
}

.call {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  column-gap: 20px; row-gap: 0;
  padding: 14px 16px 14px 18px;
  background: var(--wait-wash);
  border: 1px solid var(--wait-edge);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .12s;
}
.call:hover { border-color: var(--wait); }

.call-timer { display: flex; flex-direction: column; align-items: flex-start; }
.call-timer .t {
  font-family: var(--font-mono);
  font-size: 40px; font-weight: 600; line-height: 1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: var(--wait);
}
.call-timer .l {
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  margin-top: 6px;
}

.call-proj {
  margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.015em; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.call-org {
  margin: 1px 0 0; font-size: 12.5px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.call-msg { margin: 7px 0 0; font-size: 14.5px; color: var(--ink); }
.call-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.call-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 7px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.call-quiet {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 20px; border: 1px dashed var(--line); border-radius: 8px;
  font-size: 13.5px; color: var(--dim);
}
.call-quiet::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--done); flex: none;
}

/* ── 其余：行式台账 ──────────────────────────────── */

/* 台账同样按宽度分列。阈值取 720px：低于此值四个子列会挤到项目名截断，
   宁可单列也不要挤。 */
.ledger {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(720px, 1fr));
  column-gap: 30px;
  align-items: start;
  border-top: 1px solid var(--line-soft);
}
.lrow {
  display: grid;
  grid-template-columns: 92px minmax(140px, 1fr) minmax(0, 1.7fr) auto;
  column-gap: 18px; row-gap: 0; align-items: start;
  padding: 11px 12px 11px 15px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.lrow:hover { background: var(--surface); }
.lrow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; }
.lrow.run::before { background: var(--run); }
.lrow.done::before { background: var(--done); }
.lrow.done { color: var(--faint); }

.lst { font-family: var(--font-mono); }
.lst .s { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.lrow.run .lst .s { color: var(--run); }
.lrow.done .lst .s { color: var(--done); }
.lst .w {
  display: block; font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

.lid { min-width: 0; }
.lid .p {
  display: block; font-family: var(--font-mono); font-size: 13.5px; font-weight: 500;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lrow.done .lid .p { color: var(--dim); }
.lid .o {
  display: block; font-size: 11.5px; color: var(--faint); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.lmsg { min-width: 0; }
.lmsg .m {
  display: block; font-size: 13.5px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lmsg .e {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .06em; color: var(--faint); margin-top: 3px;
}

.lmeta {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ── 事件类型标签 ────────────────────────────────── */

.tag {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.7;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 0 7px; border-radius: 3px;
  border: 1px solid var(--line); color: var(--dim);
}
.tag.need_attention { color: var(--wait); border-color: var(--wait-edge); }
.tag.done { color: var(--done); border-color: color-mix(in srgb, var(--done) 40%, transparent); }
.tag.info { color: var(--run); border-color: color-mix(in srgb, var(--run) 38%, transparent); }

/* ── 展开按钮与日志 ──────────────────────────────── */

.tl-toggle {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
  padding: 2px 8px; color: var(--faint);
  background: transparent; border-color: transparent;
}
.call:hover .tl-toggle, .lrow:hover .tl-toggle { border-color: var(--line); color: var(--dim); }
.tl-toggle:hover { color: var(--ink); border-color: var(--dim); }
.caret { font-style: normal; line-height: 1; transition: transform .15s; }
.tl-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }

.log {
  grid-column: 1 / -1;
  list-style: none;
  margin: 12px 0 2px; padding: 11px 14px;
  background: var(--sunken);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.85;
}
.log li { display: flex; gap: 14px; align-items: baseline; }
.log time { color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.log .k { flex: none; min-width: 104px; color: var(--dim); }
.log .k.need_attention { color: var(--wait); }
.log .k.done { color: var(--done); }
.log .k.info { color: var(--run); }
.log .m {
  color: var(--ink); font-family: var(--font-sans); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 事件源 ─────────────────────────────────────── */

.create-form { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.create-form input { flex: 1; min-width: 220px; }

.src-list { display: flex; flex-direction: column; gap: 10px; }
.src-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 15px 17px;
}
.src-head { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.src-name { font-weight: 600; font-size: 15px; }
.src-actions { margin-left: auto; display: flex; gap: 7px; }
.src-meta {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--faint); margin-top: 5px;
}
.src-meta .warn { color: var(--wait); }
.urlline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.urlline code {
  background: var(--sunken); border: 1px solid var(--line-soft);
  padding: 6px 9px; border-radius: 5px; color: var(--dim);
  overflow-x: auto; white-space: nowrap; flex: 1;
}
pre.snippet {
  background: var(--sunken); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: 12px; overflow-x: auto; margin: 9px 0 0;
  color: var(--dim); line-height: 1.7;
}

/* ── 设置 ───────────────────────────────────────── */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 17px 19px; margin-bottom: 14px; max-width: 660px;
}
.panel h3 {
  margin: 0 0 6px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  font-weight: 500;
}
.panel > .muted { margin: 0 0 12px; }
.form-row { display: flex; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 190px; }
.form-row .pw-field { flex: 1; min-width: 190px; }

/* ── 登录 ───────────────────────────────────────── */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 30px 28px; width: 340px; display: flex; flex-direction: column; gap: 11px;
}
.login-box h1 {
  margin: 0 0 4px;
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  letter-spacing: .02em; text-align: left;
}
.login-box .sub {
  margin: 0 0 12px; font-size: 12.5px; color: var(--faint);
}
.login-box input { width: 100%; }
.login-box button.primary { margin-top: 4px; padding: 8px; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 19px; margin: 0; }

/* 密码框 + 明文切换 */
.pw-field { position: relative; display: flex; }
.pw-field input { flex: 1; min-width: 0; padding-right: 38px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  padding: 4px; border-color: transparent; background: transparent;
  color: var(--faint); border-radius: 5px;
}
.pw-eye:hover { color: var(--ink); border-color: transparent; background: var(--raised); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 820px) {
  .lrow { grid-template-columns: 88px minmax(0, 1fr) auto; }
  .lrow .lmsg { grid-column: 2 / -1; grid-row: 2; margin-top: 4px; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar nav a { padding: 4px 8px; }
  .userbox { display: none; }
  main { padding: 16px 12px 48px; }
  .call { grid-template-columns: 1fr; gap: 12px; padding: 15px 16px; }
  .call-timer { flex-direction: row; align-items: baseline; gap: 11px; }
  .call-timer .t { font-size: 38px; }
  .call-timer .l { margin-top: 0; }
  .lrow { grid-template-columns: 1fr auto; gap: 8px 14px; }
  .lrow .lid { grid-column: 1 / -1; }
  .lrow .lmsg { grid-column: 1 / -1; grid-row: auto; }
}
