/* ------------------------------------------------------------------
   TaskHub 控制台 —— Facebook 桌面版设计语言
   色板 / 阴影 / 排版取自 facebook.com 桌面 Web 的公开视觉规范
   ------------------------------------------------------------------ */

:root {
  --blue: #1877f2;
  --blue-hover: #166fe5;
  --blue-light: #e7f3ff;
  --green: #42b72a;
  --green-hover: #36a420;
  --red: #e41e3f;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #050505;
  --text-2: #65676b;
  --text-3: #8a8d91;
  --divider: #ced0d4;
  --hover: #f2f2f2;
  --input: #f0f2f5;
  --ring: rgba(24, 119, 242, .35);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .1);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .1), 0 8px 20px rgba(0, 0, 0, .1);
  --shadow-3: 0 12px 28px rgba(0, 0, 0, .2), 0 2px 4px rgba(0, 0, 0, .1);
  --r-card: 8px;
  --r-btn: 6px;
  --font: "Segoe UI Historic", "Segoe UI", Helvetica, Arial, "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.3333;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================ 登录 */

.login-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  gap: 20px;
}

.login-head { text-align: center; }
.login-head h1 {
  margin: 10px 0 4px;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--blue);
}
.login-head p { margin: 0; color: var(--text-2); font-size: 17px; }

.fb-logo-lg svg { width: 64px; height: 64px; display: block; margin: 0 auto; }

.login-card {
  width: 100%;
  max-width: 396px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
  padding: 16px;
}

.login-card input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-size: 17px;
  border: 1px solid #dddfe2;
  border-radius: var(--r-btn);
  background: var(--card);
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
}
.login-card input::placeholder { color: #8a8d91; }
.login-card input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--ring);
}

.btn-primary, .btn-green, .btn-secondary, .btn-ghost, .btn-danger {
  border: none;
  border-radius: var(--r-btn);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease;
}

.btn-primary { background: var(--blue); color: #fff; height: 42px; font-size: 17px; padding: 0 16px; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { background: #bcc0c4; cursor: default; }

.btn-green { background: var(--green); color: #fff; height: 42px; font-size: 15px; padding: 0 16px; }
.btn-green:hover { background: var(--green-hover); }

.btn-secondary { background: #e4e6eb; color: var(--text); height: 36px; font-size: 15px; padding: 0 12px; }
.btn-secondary:hover { background: #d8dadf; }

.btn-ghost { background: transparent; color: var(--text-2); height: 34px; padding: 0 10px; font-size: 14px; }
.btn-ghost:hover { background: var(--hover); }

.btn-danger { background: #f5f6f7; color: var(--red); height: 34px; padding: 0 12px; font-size: 14px; }
.btn-danger:hover { background: #ffe9ec; }

.btn-lg { width: 100%; height: 48px; font-size: 20px; }
.btn-block { width: 100%; }

.login-row { text-align: center; margin-top: 14px; font-size: 14px; }
.login-row a { color: var(--blue); }

.login-sep {
  height: 1px;
  background: var(--divider);
  margin: 18px 0;
}

.setup-hint { color: var(--text-2); font-size: 14px; margin-bottom: 12px; }

.server-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--divider); }
.server-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.server-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  border: 1px solid #dddfe2;
  border-radius: var(--r-btn);
  margin-bottom: 10px;
  outline: none;
}

.login-foot { font-size: 13px; color: var(--text-3); text-align: center; }

/* ============================================================ 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.topbar-left { display: flex; align-items: center; gap: 8px; width: 320px; flex: none; }
.logo-pill svg { width: 40px; height: 40px; display: block; }

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: var(--input);
  border-radius: 20px;
  flex: 1;
  color: var(--text-2);
}
.search-pill .ic { width: 16px; height: 16px; flex: none; }
.search-pill input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  width: 100%;
}

.topbar-nav { display: flex; align-items: center; gap: 8px; height: 100%; }
.nav-tab {
  width: 112px;
  height: 48px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-tab svg { width: 26px; height: 26px; }
.nav-tab:hover { background: var(--hover); }
.nav-tab.is-active { color: var(--blue); }
.nav-tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -4px;
  height: 3px;
  background: var(--blue);
  border-radius: 3px 3px 0 0;
}

.topbar-right { display: flex; align-items: center; gap: 8px; width: 320px; justify-content: flex-end; position: relative; }

.me {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 4px;
  border-radius: 20px;
  background: #e4e6eb;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.me:hover { background: #d8dadf; }
.me-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  text-transform: uppercase;
}
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: #e4e6eb;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #d8dadf; }
.icon-btn svg { width: 20px; height: 20px; }

.menu-pop {
  position: absolute;
  top: 52px;
  right: 0;
  width: 300px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-3);
  padding: 8px;
  z-index: 80;
}
.menu-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.menu-user .avatar { width: 36px; height: 36px; }
.menu-user b { font-size: 15px; }
.menu-sep { height: 1px; background: var(--divider); margin: 6px 0; }
.menu-pop button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.menu-pop button:hover { background: var(--hover); }
.menu-pop button.danger { color: var(--red); font-weight: 600; }

/* ============================================================ 布局 */

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 680px) 320px;
  gap: 24px;
  justify-content: center;
  padding: 20px 16px 60px;
  align-items: start;
}

.side-left, .side-right { position: sticky; top: 76px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.side-item:hover { background: #e4e6eb; }
.side-item.is-active { background: var(--blue-light); color: var(--blue); }
.side-ic {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #e4e6eb;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.side-item.is-active .side-ic { background: var(--blue); color: #fff; }
.side-ic svg { width: 20px; height: 20px; }
.side-count { margin-left: auto; font-size: 13px; color: var(--text-2); font-weight: 500; }

.side-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-2);
  padding: 16px 10px 6px;
}

/* ============================================================ 卡片 */

.card {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-pad { padding: 16px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 8px;
}
.card-head .who { min-width: 0; }
.card-head .name { font-weight: 600; font-size: 15px; }
.card-head .meta { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.card-body { padding: 4px 16px 12px; }
.card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-top: 1px solid var(--divider);
}
.act {
  flex: 1;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
}
.act:hover { background: var(--hover); }
.act.blue { color: var(--blue); }
.act.danger { color: var(--red); }

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}
.composer .fake-input {
  flex: 1;
  height: 40px;
  border-radius: 20px;
  background: var(--input);
  color: var(--text-2);
  font-size: 15px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  cursor: pointer;
}
.composer .fake-input:hover { background: #e4e6eb; }

/* 徽标 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  background: #e4e6eb;
  color: var(--text-2);
}
.chip.ok { background: #e5f6e3; color: #1f7a12; }
.chip.err { background: #ffe9ec; color: #b3122b; }
.chip.warn { background: #fff4e0; color: #9a6400; }
.chip.blue { background: var(--blue-light); color: var(--blue); }

.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none;
}
.dot.on { background: var(--green); }

/* 代码块 / 输出 */
.code {
  background: #f5f6f7;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
  color: #1c1e21;
  margin: 0;
}
.code.err { background: #fff5f5; color: #a0122a; }

.attach {
  display: block;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--divider);
  background: #f5f6f7;
}
.attach img { display: block; width: 100%; max-height: 520px; object-fit: contain; }
.attach .file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
}
.attach .file-row + .file-row { border-top: 1px solid var(--divider); }
.attach .file-row:hover { background: var(--hover); }

/* 空状态 */
.empty {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty h4 { margin: 0 0 6px; font-size: 17px; color: var(--text); }
.empty p { margin: 0; font-size: 14px; }

/* ============================================================ 列表 / 表 */

.row-list { display: flex; flex-direction: column; }

.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.row-item:hover { background: var(--hover); }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .t1 { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .t2 { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f7f8fa; }

/* 开关 */
.switch {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
  font-weight: 400;
  color: var(--text);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: #8a8d91;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .18), 0 0 0 1px rgba(0, 0, 0, .04);
  position: relative;
  transition: background .15s ease;
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.switch input:checked + .track { background: var(--blue); box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch .switch-label { font-size: 14px; font-weight: 600; color: var(--text); }
.switch .switch-hint { font-size: 13px; color: var(--text-2); font-weight: 400; }

/* 设置页里的开关行：整行可点，和卡片有明确分隔 */
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: #f5f6f7;
  border: 1px solid var(--divider);
  border-radius: 8px;
  margin-bottom: 14px;
  font-weight: 600;
}

/* ============================================================ 表单 */

.field { margin-bottom: 14px; }
/* 注意排除 .switch：否则这里的 display:block 会盖掉 .switch 的 inline-flex，
   开关会被拽成块级元素、背景和卡片融为一体。 */
.field > label:not(.switch):not(.switch-row) {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input[type=text], .field input[type=number], .field input[type=password],
.field select, .field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: 6px;
  outline: none;
}
.field textarea { resize: vertical; font-family: Consolas, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--ring);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* 上传进度条 */
.progress {
  height: 8px;
  border-radius: 4px;
  background: #e4e6eb;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--blue);
  transition: width .18s linear;
  background-image: linear-gradient(90deg, #1877f2, #4a97f7);
}
.progress.done .progress-bar { background: var(--green); background-image: none; }
.progress.err .progress-bar { background: var(--red); background-image: none; }
.upload-status { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.upload-status.err { color: var(--red); }
.upload-status.ok { color: #1f7a12; font-weight: 600; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  height: 34px; padding: 0 14px;
  border: 1px solid var(--divider);
  background: var(--card);
  border-radius: 6px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  color: var(--text-2); cursor: pointer;
}
.seg button:hover { background: var(--hover); }
.seg button.is-active { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* ============================================================ 右栏 */

.rail-card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: 12px; margin-bottom: 16px; }
.rail-title { font-size: 15px; font-weight: 600; color: var(--text-2); padding: 0 4px 8px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: #f5f6f7;
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat.wide { grid-column: span 2; }

/* ============================================================ 弹层 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 40px;
  overflow: auto;
}
.modal {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.modal.wide { max-width: 760px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
}
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 700; }
.modal-head .icon-btn { background: var(--input); }
.modal-body { padding: 16px; max-height: 64vh; overflow: auto; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  background: #fafbfc;
}

/* ============================================================ 提示 */

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 300;
  background: #303338;
  color: #fff;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-2);
  max-width: 420px;
}
.toast.ok { background: #1f7a12; }
.toast.err { background: #b3122b; }

.loader {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(240, 242, 245, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 38px; height: 38px;
  border: 4px solid #ccd0d5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ 响应式 */

@media (max-width: 1240px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .side-right { display: none; }
}
@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-left { display: none; }
  .topbar-nav { display: none; }
  .topbar-left, .topbar-right { width: auto; }
}
