* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: #f5f7fa;
  color: #333;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.admin-sidebar {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 20px 0;
}

.sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid #eef0f2;
}

.brand-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.brand-subtitle {
  font-size: 12px;
  color: #9ca3af;
}

.sidebar-menu {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.menu-item:hover {
  background: #eef2ff;
  color: #4f46e5;
}

.menu-item.active {
  background: #e0e7ff;
  color: #4f46e5;
  font-weight: 600;
}

.menu-icon {
  font-size: 16px;
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.25);
}

.admin-title {
  font-size: 18px;
  font-weight: 600;
}

.admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.page-section {
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.stat-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 20px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
}

.stat-label {
  font-size: 12px;
  color: #9ca3af;
}

.table-shell {
  background: #fff;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: #374151;
}

.empty-data {
  text-align: center;
  color: #9ca3af;
  padding: 32px !important;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.field input {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-secondary {
  background: #eef2ff;
  color: #4338ca;
}

.btn-danger {
  background: linear-gradient(135deg, #f5576c 0%, #ef4444 100%);
  color: #fff;
}

.legend {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: #6b7280;
}

.lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.lamp.green { background: #10b981; }
.lamp.gray { background: #9ca3af; }

.table {
  display: grid;
  gap: 6px;
}

.table.empty {
  padding: 12px;
  background: #f8fafc;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 140px 1fr 120px 1.4fr;
  gap: 12px;
  align-items: center;
}

.table-head {
  font-size: 12px;
  color: #6b7280;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
}

.table-row {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 8px;
}

.link-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: #4f46e5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.pill.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.pill.secondary {
  background: #e5e7eb;
  color: #374151;
}

.pill.danger {
  background: #ef4444;
  color: #fff;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.status-chip .lamp {
  margin-right: 0;
}

.status-chip.green {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.status-chip.gray {
  background: rgba(156, 163, 175, 0.15);
  color: #6b7280;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
}

.feed {
  display: grid;
  gap: 8px;
}


.log-list {
  display: grid;
  gap: 8px;
}

.log-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.log-main {
  display: grid;
  gap: 4px;
}

.log-action {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.log-detail {
  font-size: 12px;
  color: #6b7280;
  word-break: break-word;
}

.log-meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
  text-align: right;
  min-width: 120px;
}

.log-ip {
  font-weight: 600;
}

.feed .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.empty-state {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  padding: 12px;
}

.cleanup-body {
  display: grid;
  gap: 8px;
}

.cleanup-status.enabled { color: #10b981; }
.cleanup-status.disabled { color: #ef4444; }

.search-input {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.select-input {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}

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

.assign-collapse-btn {
  padding: 6px 12px;
  font-size: 12px;
}

#assign-panel.assign-collapsed .panel-head {
  margin-bottom: 0;
}

#assign-panel.assign-collapsed .assign-toolbar,
#assign-panel.assign-collapsed .assign-table {
  display: none;
}


.assign-table {
  display: grid;
  gap: 6px;
  max-height: min(62vh, 720px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 4px;
}

.assign-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

.assign-head,
.assign-row {
  display: grid;
  grid-template-columns: 160px 140px 1fr 1.2fr 70px 220px;
  gap: 12px;
  align-items: center;
}

.assign-head {
  font-size: 12px;
  color: #6b7280;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
}

.assign-row {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 8px;
}

.assign-visitor {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
}

.assign-visitor strong {
  color: #111827;
}

.assign-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.assign-actions select {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
}

.assign-note {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
}

.delegate-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.delegate-arrow {
  font-size: 14px;
  color: #6b7280;
}

.delegate-table {
  display: grid;
  gap: 6px;
}

.delegate-head,
.delegate-row {
  display: grid;
  grid-template-columns: 1fr 1fr 160px 120px;
  gap: 12px;
  align-items: center;
}

.delegate-head {
  font-size: 12px;
  color: #6b7280;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
}

.delegate-row {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 8px;
}

.switch-label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
}

.login-gate {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: grid;
  place-items: center;
  z-index: 60;
}

.login-gate.hidden {
  display: none;
}

.login-card {
  width: min(360px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

.hidden {
  display: none;
}

@media (max-width: 1024px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
  .menu-item {
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .table-head,
  .table-row {
    grid-template-columns: 140px 1fr;
  }
  /* Keep operation buttons visible on small screens; only hide the TG/status column. */
  .table-head span:nth-child(3),
  .table-row > :nth-child(3) {
    display: none;
  }
  .table-row .actions {
    grid-column: 1 / -1;
  }
  .assign-head,
  .assign-row {
    grid-template-columns: 1fr 160px;
  }
  .assign-head span:nth-child(2),
  .assign-head span:nth-child(3),
  .assign-head span:nth-child(4),
  .assign-head span:nth-child(5),
  .assign-row > :nth-child(2),
  .assign-row > :nth-child(3),
  .assign-row > :nth-child(4),
  .assign-row > :nth-child(5) {
    display: none;
  }
  .delegate-head,
  .delegate-row {
    grid-template-columns: 1fr 120px;
  }
  /* Keep operation buttons visible on small screens; only hide the "更新时间" column. */
  .delegate-head span:nth-child(3),
  .delegate-row > :nth-child(3) {
    display: none;
  }
  .delegate-row > :nth-child(4) {
    display: block;
  }
}


.force-mobile .admin-shell {
  grid-template-columns: 1fr;
}

.force-mobile .admin-sidebar {
  border-right: none;
  border-bottom: 1px solid #e5e7eb;
}

.force-mobile .sidebar-menu {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  overflow-x: auto;
  padding-bottom: 8px;
}

.force-mobile .menu-item {
  justify-content: center;
  white-space: nowrap;
}

.force-mobile .admin-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.force-mobile .admin-actions {
  width: 100%;
  flex-wrap: wrap;
}

.force-mobile .page-section {
  padding: 16px;
}

.force-mobile .panel {
  padding: 12px;
}

.force-mobile .form-grid {
  grid-template-columns: 1fr;
}

.force-mobile .table-head,
.force-mobile .assign-head,
.force-mobile .delegate-head {
  display: none;
}

.force-mobile .table-row {
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}

.force-mobile .assign-row,
.force-mobile .delegate-row {
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}

.force-mobile .log-item {
  flex-direction: column;
  align-items: flex-start;
}

.force-mobile .log-meta {
  text-align: left;
  min-width: 0;
}

.force-mobile .feed .item {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
