/* ===================================================================
   服务门户样式（浅色简约 + 自动夜间模式）
   变量：--bg 页面底色 / --card 卡片底色 / --primary 主色 / --muted 次要文字
   =================================================================== */

:root {
  --bg: #f4f6fb;
  --bg-glow: radial-gradient(1100px 520px at 50% -180px, rgba(37, 99, 235, .10), rgba(37, 99, 235, 0) 70%);
  --card: #ffffff;
  --text: #1b2330;
  --muted: #667085;
  --border: #e6e9f0;
  --border-strong: #d5dbe6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-weak: #eaf1ff;
  --danger: #d92d20;
  --shadow-sm: 0 1px 2px rgba(23, 35, 61, .06);
  --shadow-md: 0 16px 36px -16px rgba(23, 35, 61, .25);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-bs-theme="dark"] {
  --bg: #0e1117;
  --bg-glow: radial-gradient(1100px 520px at 50% -180px, rgba(96, 138, 255, .16), rgba(96, 138, 255, 0) 70%);
  --card: #161b23;
  --text: #e7ebf3;
  --muted: #97a1b2;
  --border: #262d3a;
  --border-strong: #3a4352;
  --primary: #6b93ff;
  --primary-hover: #8aa8ff;
  --primary-weak: #1b2740;
  --danger: #f97066;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 18px 40px -18px rgba(0, 0, 0, .8);
}

html {
  color-scheme: light dark;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* ---------- 前台门户 ---------- */

.portal-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 46px 20px 28px;
}

.portal-hero {
  padding: 10px 8px 6px;
  text-align: center;
}

.portal-hero h1 {
  margin: 0 0 10px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .5px;
}

.portal-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.portal-section {
  margin-top: 40px;
}

.portal-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}

.portal-section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
}

.portal-section-count {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
}

.site-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.site-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

.site-card-head {
  display: flex;
  align-items: center;
  gap: 13px;
}

.site-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--icon-grad, linear-gradient(135deg, #4f7cff, #2563eb));
  color: #fff;
  font-size: 22px;
}

.site-icon:has(.icon-emoji),
.site-icon:has(.icon-letter) {
  background: var(--primary-weak);
  box-shadow: inset 0 0 0 1px var(--border);
}

.icon-emoji {
  font-size: 23px;
  line-height: 1;
}

.icon-letter {
  color: var(--primary);
  font-size: 19px;
  font-weight: 700;
}

.icon-svg {
  display: block;
  width: 23px;
  height: 23px;
}

/* 图标底色：按卡片序号轮换的多彩渐变 */
.site-grid .site-card:nth-child(6n+1) .site-icon {
  --icon-grad: linear-gradient(135deg, #4f7cff, #2563eb);
}

.site-grid .site-card:nth-child(6n+2) .site-icon {
  --icon-grad: linear-gradient(135deg, #2dd4bf, #0d9488);
}

.site-grid .site-card:nth-child(6n+3) .site-icon {
  --icon-grad: linear-gradient(135deg, #a78bfa, #7c3aed);
}

.site-grid .site-card:nth-child(6n+4) .site-icon {
  --icon-grad: linear-gradient(135deg, #fbbf24, #d97706);
}

.site-grid .site-card:nth-child(6n+5) .site-icon {
  --icon-grad: linear-gradient(135deg, #fb7185, #e11d48);
}

.site-grid .site-card:nth-child(6n+6) .site-icon {
  --icon-grad: linear-gradient(135deg, #34d399, #059669);
}

.site-card-name {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.35;
}

.site-card-desc {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.site-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  margin-top: auto;
}

.visit-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.site-card-go {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.portal-footer {
  flex-shrink: 0;
  padding: 26px 16px 30px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.portal-footer a {
  color: var(--muted);
}

.portal-footer a:hover {
  color: var(--primary);
}

.portal-footer-sep {
  margin: 0 8px;
}

/* 备案号行（工信部备案系统链接） */
.portal-footer-beian {
  margin-top: 6px;
}

/* ---------- 通用组件 ---------- */

.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 13.5px;
}

.notice-ok {
  background: rgba(18, 183, 106, .09);
  border-color: rgba(18, 183, 106, .30);
  color: #12805c;
}

.notice-err {
  background: rgba(217, 45, 32, .08);
  border-color: rgba(217, 45, 32, .30);
  color: #b42318;
}

[data-bs-theme="dark"] .notice-ok {
  color: #75e0a7;
}

[data-bs-theme="dark"] .notice-err {
  color: #fda29b;
}

.btn-portal,
.btn-portal:focus {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
}

.btn-portal:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-ghost,
.btn-ghost:focus {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger-soft,
.btn-danger-soft:focus {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger-soft:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ---------- 后台 ---------- */

.admin-shell {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 48px;
}

.admin-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 4px;
  padding: 10px 14px;
  margin-bottom: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.admin-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f7cff, #2563eb);
}

.admin-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.admin-nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.admin-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
}

.admin-nav-link:hover {
  background: var(--bg);
  color: var(--text);
}

.admin-nav-link.active {
  background: var(--primary-weak);
  color: var(--primary);
  font-weight: 600;
}

.panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel+.panel {
  margin-top: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
}

.panel-sub {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.table-wrap {
  overflow-x: auto;
}

.table-portal {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table-portal th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table-portal td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-portal tbody tr:last-child td {
  border-bottom: none;
}

.table-portal tbody tr:hover td {
  background: var(--bg);
}

.table-url {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.badge-soft {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 12px;
  white-space: nowrap;
}

.badge-soft.muted {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.mini-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f7cff, #2563eb);
  color: #fff;
  font-size: 17px;
}

.mini-icon:has(.icon-emoji),
.mini-icon:has(.icon-letter) {
  background: var(--primary-weak);
  box-shadow: inset 0 0 0 1px var(--border);
}

.mini-icon .icon-svg {
  width: 18px;
  height: 18px;
}

/* ---------- 统计 ---------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  color: var(--muted);
  font-size: 12.5px;
}

.stat-card-value {
  margin-top: 6px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.2;
}

.stat-card-value small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.seg a {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.seg a:hover {
  color: var(--text);
}

.seg a.active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.bar {
  min-width: 90px;
  height: 8px;
  overflow: hidden;
  background: var(--bg);
  border-radius: 999px;
}

.bar>i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f7cff, #2563eb);
}

/* ---------- 图标选择器 ---------- */

.picker-section {
  margin-top: 14px;
}

.picker-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  max-height: 264px;
  padding: 12px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.icon-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 21px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.icon-choice:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.icon-choice.selected {
  border-color: var(--primary);
  background: var(--primary-weak);
  box-shadow: 0 0 0 1px var(--primary);
}

.icon-choice .icon-svg {
  width: 21px;
  height: 21px;
}

.icon-choice.icon-choice-none {
  grid-column: 1 / -1;
  width: 100%;
  height: 40px;
  color: var(--muted);
  font-size: 13px;
}

.icon-choice.icon-choice-none.selected {
  color: var(--primary);
}

/* ---------- 表单 ---------- */

.form-label {
  color: var(--muted);
  font-size: 13px;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
}

.form-control,
.form-select {
  font-size: 13.5px;
}

/* ASP.NET Core 表单校验状态 */
.validation-summary-valid {
  display: none;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 18px;
}

.field-validation-error {
  color: var(--danger);
  font-size: 12.5px;
}

.field-validation-valid {
  display: none;
}

/* ---------- 登录页 ---------- */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 18px;
}

.login-card {
  width: 100%;
  max-width: 384px;
  padding: 30px 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 其他 ---------- */

.empty-tip {
  padding: 40px 0;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
  .portal-main {
    padding-top: 30px;
  }

  .portal-hero h1 {
    font-size: 26px;
  }

  .portal-hero p {
    font-size: 13.5px;
  }

  .admin-shell {
    padding: 14px 12px 36px;
  }

  .admin-nav-right {
    margin-left: 0;
  }

  .panel {
    padding: 16px;
  }

  .stat-card-value {
    font-size: 23px;
  }
}