/* ============================================================
   微博采集 · 管理后台样式
   设计语言沿用 DESIGN.md：中性色主导 + 单一品牌橙 #eb7350。
   字号只用 16 / 15 / 13 / 12 / 11 五级，圆角只用 3 / 6 / 8 / 12。
   ============================================================ */

:root {
  --primary: #eb7350;
  --primary-hover: #d85f3c;
  --primary-ring: rgba(235, 115, 80, 0.14);
  --primary-soft: rgba(235, 115, 80, 0.1);

  --text-primary: #1f2329;
  --text-strong: #303540;
  --text-body: #4e5461;
  --text-muted: #646a73;
  --text-meta: #8a9099;
  --text-faint: #a0a5ad;

  --border-default: #dcdfe5;
  --border-hover: #b9bec7;
  --border-hairline: #eef0f2;

  --bg-surface: #fff;
  --bg-page: #fafbfc;
  --bg-subtle: #f7f8fa;
  --bg-hover: #f3f4f6;
  --bg-badge: #f2f3f5;

  --success: #2b8a5b;
  --success-bg: #eef8f2;
  --warn: #b7791f;
  --error: #b5432a;
  --error-bg: #fff2ef;

  --shadow-dialog: 0 12px 40px rgba(0, 0, 0, 0.22);
  --shadow-toast: 0 6px 20px rgba(0, 0, 0, 0.2);

  --sidebar-width: 208px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

code {
  font-family: inherit;
  background: var(--bg-badge);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--text-strong);
}

.hidden {
  display: none !important;
}

.sub {
  font-size: 12px;
  color: var(--text-meta);
  line-height: 1.6;
}

.mono-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 登录 ---------------- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 22px;
}

.login-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.login-head h1 {
  font-size: 15px;
  font-weight: 500;
}

.brand-mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-strong);
  margin-bottom: 5px;
}

.hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.6;
}

/* ---------------- 表单控件 ---------------- */

.input,
.select,
.textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  resize: vertical;
  min-height: 96px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-ring);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-meta) 50%),
    linear-gradient(135deg, var(--text-meta) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
  cursor: pointer;
}

.btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-strong);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-body);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: transparent;
}

.btn-danger {
  color: var(--error);
  border-color: var(--border-default);
  background: var(--bg-surface);
}

.btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

.btn-link {
  border: none;
  background: none;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-body);
  cursor: pointer;
  border-radius: 3px;
}

.btn-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
  margin-top: 4px;
}

/* ---------------- 布局 ---------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.brand-text strong {
  font-size: 13px;
  font-weight: 500;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-meta);
}

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

.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-body);
}

.nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 500;
}

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-faint);
}

.nav a.active .nav-dot {
  background: var(--primary);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 6px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 12px;
}

.health {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-meta);
}

.health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.health.ok .health-dot {
  background: var(--success);
}

.health.error .health-dot {
  background: var(--error);
}

.ext-link {
  font-size: 11px;
  color: var(--text-meta);
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.ext-link:hover {
  color: var(--primary);
}

.main {
  min-width: 0;
  padding: 20px 28px 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 18px;
}

.topbar-title h1 {
  font-size: 15px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view {
  max-width: 1180px;
}

/* ---------------- 卡片 / 统计 ---------------- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
}

.card-head h2 {
  font-size: 13px;
  font-weight: 500;
}

.card-body {
  padding: 14px 18px 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-meta);
}

.stat-value {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: 11px;
  color: var(--text-faint);
}

.stat.accent .stat-value {
  color: var(--primary-hover);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

/* 近 14 天柱状图：纯 CSS，无图表库 */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 108px;
  padding-top: 8px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 26px;
  min-height: 2px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.chart-col:hover .chart-bar {
  opacity: 1;
}

.chart-x {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.bar-row .name {
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-badge);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  opacity: 0.8;
  border-radius: 3px;
}

.bar-row .value {
  text-align: right;
  color: var(--text-meta);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 工具栏 ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  flex: 1 1 240px;
  min-width: 180px;
}

.search-box .input {
  padding-left: 30px;
}

.search-box::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -6px;
  border: 1.5px solid var(--text-faint);
  border-radius: 50%;
  pointer-events: none;
}

.search-box::after {
  content: '';
  position: absolute;
  left: 19px;
  top: 50%;
  width: 5px;
  height: 1.5px;
  margin-top: 4px;
  background: var(--text-faint);
  transform: rotate(45deg);
  pointer-events: none;
}

.toolbar .select {
  width: auto;
  min-width: 128px;
}

.toolbar-spacer {
  flex: 1;
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--primary-soft);
  border: 1px solid rgba(235, 115, 80, 0.28);
  border-radius: 6px;
  font-size: 12px;
  color: var(--primary-hover);
}

/* ---------------- 表格 ---------------- */

.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

/* 话题表只有 4 列，限宽避免「名称」列被拉得过长 */
.table-compact {
  max-width: 820px;
}

.table th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-meta);
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}

.table td {
  font-size: 13px;
  color: var(--text-strong);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--bg-page);
}

.table .col-check {
  width: 34px;
  padding-right: 0;
}

.table .col-time {
  width: 128px;
  white-space: nowrap;
  color: var(--text-meta);
  font-size: 12px;
}

.table .col-topic {
  width: 118px;
}

.table .col-actions {
  width: 96px;
  text-align: right;
  white-space: nowrap;
}

.cell-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cell-text {
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.55;
}

.cell-meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1.6;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--bg-badge);
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-topic {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.tag-warn {
  background: #fdf3e2;
  color: var(--warn);
}

.tag-none {
  background: var(--bg-badge);
  color: var(--text-faint);
}

.checkbox {
  width: 13px;
  height: 13px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 3px 0 0;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.empty strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ---------------- 分页 ---------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--text-meta);
  background: var(--bg-surface);
}

.pagination .pages {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------------- 话题集合 ---------------- */

.topic-create {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  max-width: 420px;
}

.topic-name-input {
  padding: 5px 8px;
}

.count-pill {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--bg-badge);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 抽屉 ---------------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.28);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-dialog);
  z-index: 41;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-hairline);
}

.drawer-head h2 {
  font-size: 15px;
  font-weight: 500;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 抽屉内的字段间距由父级 gap 统一控制，避免叠加成双倍留白 */
.drawer-body .field {
  margin-bottom: 0;
}

.drawer-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
}

.drawer-foot .spacer {
  flex: 1;
}

.meta-grid {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 12px;
  color: var(--text-body);
}

.meta-grid dt {
  color: var(--text-meta);
}

.meta-grid dd {
  margin: 0;
  word-break: break-all;
}

.link-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.link-row .input {
  font-size: 12px;
  color: var(--text-muted);
}

.char-count {
  text-align: right;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

.error-block {
  background: var(--error-bg);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--error);
}

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 60;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: #fff;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-toast);
  animation: toast-in 0.18s ease-out;
  max-width: 320px;
}

.toast.error {
  background: var(--error);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------- 确认弹窗 ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-dialog);
  padding: 18px;
}

.modal h2 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}

.modal p {
  font-size: 12px;
  color: var(--text-body);
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-hairline);
    padding: 10px 16px;
    overflow-x: auto;
  }

  .brand-text,
  .sidebar-foot .ext-link {
    display: none;
  }

  .nav {
    flex-direction: row;
  }

  .sidebar-foot {
    margin: 0 0 0 auto;
    border: none;
    padding: 0;
    flex-direction: row;
    align-items: center;
  }

  .main {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .table .col-topic {
    display: none;
  }
}

/* ------------------------------ 访问令牌 ------------------------------ */

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.token-once {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-subtle);
  word-break: break-all;
}

.token-once code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text-primary);
}
