:root {
  --bg: #eef6f1;
  --bg2: #d8f3e3;
  --card: #ffffff;
  --line: #e4eee8;
  --text: #1a1a1a;
  --muted: #7a8580;
  --green: #07c160;
  --green-soft: #e8f8ee;
  --gold: #f5a623;
  --warn: #ff8a3d;
  --live: #07c160;
  --danger: #e23d00;
  --shadow: 0 10px 30px rgba(16, 64, 40, 0.06);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 220px, var(--bg) 100%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea { font: inherit; }
a { color: var(--green); }
.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card, .card, .stats article, .streamer, .fb-card, .user-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.login-card {
  width: min(400px, 100%);
  padding: 36px 32px 28px;
}
.login-sub {
  color: var(--muted);
  margin: 10px 0 28px;
  font-size: 14px;
  line-height: 1.5;
}
.login-field {
  display: block;
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.login-field span {
  display: block;
  margin-bottom: 8px;
}
.login-field input {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: #f6faf7;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-field input:focus {
  border-color: #8fdcb0;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
  background: #fff;
}
.login-btn {
  margin-top: 8px;
}
.login-card .msg {
  margin: 12px 0 0;
  min-height: 1.2em;
  text-align: center;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 14px; height: 28px; border-radius: 8px; background: var(--green);
}
.brand h1, .brand strong { margin: 0; font-size: 28px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px;
  background: rgba(232, 248, 238, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.tab.on { background: #fff; color: var(--text); font-weight: 650; box-shadow: var(--shadow); }
.badge {
  display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 4px; border-radius: 999px; background: var(--warn); color: #fff;
  font-size: 11px; align-items: center; justify-content: center;
}
.workspace { max-width: 1120px; margin: 0 auto; padding: 20px 20px 64px; }
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stats article { padding: 16px 18px; }
.stats span { color: var(--muted); font-size: 13px; }
.stats strong { display: block; margin-top: 6px; font-size: 28px; }
.stats .gold strong { color: #c45a00; }
.stats .warn strong { color: var(--warn); }
.cookie-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}
.cookie-banner.ok { background: var(--green-soft); color: var(--green); }
.cookie-banner.expired { background: #ffe8e0; color: var(--danger); }
.cookie-banner.missing, .cookie-banner.unknown { background: #fff4e5; color: #c45a00; }
.cookie-status { font-weight: 650; margin: 8px 0 12px; font-size: 13px; }
.cookie-status.ok { color: var(--green); }
.cookie-status.expired { color: var(--danger); }
.cookie-status.missing, .cookie-status.unknown { color: #c45a00; }
.panel { display: none; }
.panel.on { display: block; }
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card { padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card h2 { margin: 0 0 8px; font-size: 18px; }
.lead, .hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.lead { margin: 0 0 14px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.form label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
.form input, .form textarea, .form select {
  width: 100%; margin-top: 6px; border: 1px solid var(--line); background: #f6faf7;
  color: var(--text); border-radius: 12px; padding: 10px 12px;
}
.form.compact { margin: 0; }
.import-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 12px 0;
}
.import-bar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.import-bar input[type="date"],
.import-bar input[type="file"] {
  border: 1px solid var(--line);
  background: #f6faf7;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}
.import-bar .check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.import-table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.import-table th,
.import-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
.import-table th {
  position: sticky;
  top: 0;
  background: #f6faf7;
  z-index: 1;
}
.import-table input[type="text"],
.import-table input[type="datetime-local"],
.import-table select {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
}
.import-combo {
  margin-top: 0;
  min-width: 180px;
}
.import-combo .combo-input {
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.import-combo .combo-menu {
  z-index: 40;
  max-height: 240px;
}
.import-combo .combo-item {
  padding: 6px 8px;
}
.import-combo .combo-item b {
  font-size: 13px;
}
.import-status {
  white-space: nowrap;
  color: var(--muted);
}
.import-status.ok { color: #1a7f37; }
.import-status.warn { color: #b54708; }
.import-status.bad { color: #b42318; }
.field-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
}
.field-line input,
.field-line textarea {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}
.field-clear {
  flex-shrink: 0;
  margin-top: 10px;
  font-size: 12px;
  white-space: nowrap;
}
.field-line textarea + .field-clear {
  margin-top: 12px;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.primary, .ghost, .text-btn, .act, .chip {
  border: 0; cursor: pointer;
}
.primary {
  width: 100%; margin-top: 8px; background: var(--green); color: #fff;
  border-radius: 12px; padding: 12px; font-weight: 650;
}
.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 14px;
}
.ghost.full { width: 100%; margin-top: 8px; }
.text-btn { background: none; color: var(--green); padding: 0; }
.msg { min-height: 1.2em; color: #c45a00; font-size: 13px; }
.error { color: var(--danger); font-size: 12px; margin: 8px 0 0; }
.quota-line { color: var(--muted); font-size: 13px; }

.streamer, .user-card, .fb-card {
  padding: 16px;
}
.streamer {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}
.streamer.has-fudai {
  border-color: #ffd37a;
  background: linear-gradient(180deg, #fff8e8, #fff);
}
.fudai-line {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #ffd37a;
  border-radius: 12px;
  padding: 8px 10px;
}
.fudai-tag {
  background: #ff8a00;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.fudai-main { flex: 1; min-width: 0; }
.fudai-prize { color: #7a3e00; font-size: 13px; font-weight: 650; }
.fudai-cond { margin-top: 2px; color: #9a6a2a; font-size: 12px; font-weight: 500; line-height: 1.4; }
.fudai-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.fudai-people { color: #8a6a3a; font-size: 12px; font-weight: 650; line-height: 1.2; }
.fudai-cd {
  font-size: 22px;
  font-weight: 800;
  color: #e67e00;
  font-variant-numeric: tabular-nums;
}
.fudai-line.urgent { border-color: #ff7a3d; background: #fff4ec; }
.fudai-line.urgent .fudai-cd { color: #e23d00; }
.avatar { width: 56px; height: 56px; border-radius: 16px; object-fit: cover; background: #e8eeea; }
.meta h3 { margin: 0; font-size: 16px; }
.meta p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.pills { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 700;
  background: #eef1f3; color: var(--muted);
}
.pill.live { background: var(--green-soft); color: var(--green); }
.pill.fudai { background: #fff4d6; color: #c45a00; }
.actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }
.actions .act, .user-card .act {
  flex: 1; text-align: center; text-decoration: none; color: var(--text);
  background: #f3f7f4; padding: 10px 0; border-radius: 10px; font-size: 13px;
}
.actions .act.danger { color: var(--danger); }

.user-card { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.user-card .meta { flex: 1; min-width: 0; }
.user-card .act { min-width: 88px; flex: 0 0 88px; margin-top: 2px; }
.user-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.user-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.user-follows { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.user-follow {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: #f3f7f4; border-radius: 999px; padding: 3px 8px 3px 3px;
  font-size: 12px; color: var(--text);
}
.user-follow img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: #e8eeea; }
.user-follow b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.user-follow i { font-style: normal; color: var(--green); font-weight: 700; }
.user-follow.live { background: var(--green-soft); }
.user-follow-empty { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.search-input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}
.pager .act {
  min-width: 88px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.pager .act:disabled { opacity: 0.45; cursor: default; }

.probe-mask {
  position: fixed; inset: 0; background: rgba(16, 32, 24, 0.35); z-index: 40;
}
.probe-sheet {
  position: fixed; z-index: 41;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px 22px 24px;
}
.probe-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.probe-head strong { display: block; font-size: 18px; }
.probe-head small { display: block; color: var(--muted); margin-top: 4px; }
.probe-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 12px;
  background: #fbfefc;
}
.probe-card.bad { border-color: #ffd0c2; background: #fff8f5; }
.probe-card-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.probe-card-head span { color: var(--muted); font-size: 13px; }
.probe-url { margin-top: 6px; color: #5b6b63; font-size: 12px; word-break: break-all; }
.probe-parsed { margin: 8px 0 0; padding-left: 18px; color: #7a3e00; font-size: 13px; }
.probe-empty { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.probe-card details { margin-top: 8px; }
.probe-card summary { cursor: pointer; color: var(--green); font-size: 13px; }
.probe-card pre {
  margin: 8px 0 0;
  max-height: 360px;
  overflow: auto;
  background: #111;
  color: #e8f5ee;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: #fff; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }

.fb-card { display: flex; flex-direction: column; gap: 8px; }
.fb-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.fb-cat { font-weight: 700; }
.fb-st { font-size: 12px; color: #c45a00; background: #fff4d6; padding: 3px 8px; border-radius: 999px; }
.fb-st.done { color: var(--green); background: var(--green-soft); }
.fb-st.ignored { color: var(--muted); background: #eef1f3; }
.fb-body { white-space: pre-wrap; line-height: 1.55; }
.fb-meta { color: var(--muted); font-size: 12px; }
.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-item {
  padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.mini-item:last-child { border-bottom: 0; }
.mini-item b { display: block; margin-bottom: 4px; }
.mini-item span { color: var(--muted); font-size: 13px; }

.preview-card {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.preview-card.off { opacity: 0.72; }
.preview-card.pinned { border-color: #f0c36d; }
.pill.pin { background: #fff4d6; color: #c45a00; }
.preview-top { display: flex; align-items: center; gap: 12px; }
.preview-top .meta { flex: 1; min-width: 0; }
.preview-top h3 { margin: 0; font-size: 16px; }
.preview-top p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.preview-items { margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.preview-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; word-break: break-all; }
.pill.upcoming { background: #fff4d6; color: #c45a00; }
.pill.ongoing { background: var(--green-soft); color: var(--green); }
.pill.ended, .pill.offline { background: #eef1f3; color: var(--muted); }
.combo { position: relative; margin-top: 6px; }
.combo-input {
  width: 100%; border: 1px solid var(--line); background: #f6faf7;
  color: var(--text); border-radius: 12px; padding: 10px 12px;
}
.combo-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  max-height: 280px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 6px;
}
.combo-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px; border-radius: 10px; cursor: pointer; color: var(--text);
}
.combo-item:hover, .combo-item:focus { background: var(--green-soft); }
.combo-item img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: #e8eeea; }
.combo-item b { display: block; font-size: 14px; }
.combo-item span { display: block; color: var(--muted); font-size: 12px; }
.combo-empty { color: var(--muted); font-size: 13px; padding: 12px 8px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .topbar {
    padding: 10px 12px;
    gap: 10px;
    align-items: flex-start;
  }
  .topbar .brand { flex: 0 0 auto; }
  .tabs {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 13px;
  }
  #logoutBtn { margin-left: auto; }
  .workspace {
    padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
  }
  .user-card { flex-direction: column; align-items: stretch; }
  .card { padding: 14px; }
  .stats strong { font-size: 22px; }

  .import-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .import-bar label,
  .import-bar .import-file {
    width: 100%;
  }
  .import-bar input[type="date"],
  .import-bar input[type="file"],
  .import-bar .primary,
  .import-bar .ghost {
    width: 100%;
    min-height: 44px;
    font-size: 16px; /* 避免 iOS 聚焦放大 */
  }
  .import-bar .check {
    margin: 0;
    min-height: 44px;
  }
  .import-table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .import-table,
  .import-table thead,
  .import-table tbody,
  .import-table th,
  .import-table td,
  .import-table tr {
    display: block;
    width: 100%;
  }
  .import-table thead { display: none; }
  .import-table tr {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .import-table td {
    border: 0;
    padding: 8px 0;
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 8px;
    align-items: center;
  }
  .import-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
  }
  .import-table td:first-child {
    grid-template-columns: 1fr;
    padding-top: 0;
  }
  .import-table td:first-child::before { content: none; }
  .import-table input[type="text"],
  .import-table input[type="datetime-local"],
  .import-combo .combo-input {
    min-width: 0;
    font-size: 16px;
    min-height: 42px;
  }
  .import-combo {
    min-width: 0;
    width: 100%;
  }
  .import-combo .combo-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 45vh;
    z-index: 80;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  }
  .form input,
  .form textarea,
  .form select,
  .combo-input {
    font-size: 16px;
  }
  .primary, .ghost, .btn {
    min-height: 44px;
  }
  .probe-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    transform: none;
  }
  .search-sheet {
    width: auto;
  }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .login-card { margin: 16px; padding: 22px 18px; }
}

.search-add-bar {
  display: flex;
  gap: 10px;
  margin: 8px 0 4px;
}
.search-add-bar .search-input {
  flex: 1;
}
.search-sheet {
  width: min(640px, calc(100vw - 32px));
}
.search-hit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  max-height: min(60vh, 520px);
  overflow: auto;
}
.search-hit {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}
.search-hit .avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef3f0;
}
.search-hit .meta h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.search-hit .meta p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}
.search-hit .actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.search-hit .act.primary {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.search-hit .act.primary:disabled {
  opacity: 0.6;
  cursor: default;
}
