:root {
  --bg: #f4f5f8;
  --sidebar-bg: #152938;
  --sidebar-active: #224a64;
  --panel: #ffffff;
  --text: #1f2a37;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1570ef;
  --danger: #d72d3e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #1d3648 0%, #152938 100%);
  color: #e8eef5;
  padding: 16px;
  transition: width 0.2s;
}

.sidebar.collapsed {
  width: 88px;
}

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

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #2e5a77;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.brand-text {
  font-size: 15px;
  font-weight: 600;
}

.sidebar.collapsed .brand-text {
  display: none;
}

.collapse-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #f4f8fb;
  cursor: pointer;
}

.menu {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  border: none;
  text-align: left;
  border-radius: 8px;
  padding: 10px 12px;
  color: #d6e2ec;
  background: transparent;
  cursor: pointer;
}

.menu-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.sidebar.collapsed .menu-item {
  text-align: center;
  padding: 10px 4px;
  font-size: 12px;
}

.content {
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.api-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  background: #fff;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

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

button.danger {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.content-inner {
  padding: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.panel + .panel {
  margin-top: 12px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel h3 {
  margin: 14px 0 8px;
  font-size: 15px;
}

.tip {
  margin: 0 0 12px;
  color: var(--muted);
}

.form-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.form-row.two-col {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.stat-title {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
}

.tool-table,
.user-table,
.log-table,
.recommend-table,
.task-rule-table {
  width: 100%;
  border-collapse: collapse;
}

.tool-table th,
.tool-table td,
.user-table th,
.user-table td,
.log-table th,
.log-table td,
.recommend-table th,
.recommend-table td,
.task-rule-table th,
.task-rule-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

.tool-preview {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f4f5f8;
}

.small-input {
  width: 90px;
}

.consume-option {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text);
}

.consume-option input[type="checkbox"] {
  width: auto;
}

.consume-tip {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.tool-actions,
.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tool-table textarea {
  min-width: 220px;
}

#toolsContainer,
#categoriesContainer,
#recommendContainer,
#taskRulesContainer,
#usersContainer,
#bannerContainer,
#recentLogs {
  overflow-x: auto;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 860px) {
  .admin-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar.collapsed {
    width: 100%;
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: flex-start;
  }

  .api-box {
    width: 100%;
  }

  .form-row.two-col {
    grid-template-columns: 1fr;
  }
}
