@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --primary: #2f8f84;
  --primary-deep: #1f6f67;
  --primary-soft: rgba(47, 143, 132, .12);
  --gold: #b8956a;
  --text: #1a2430;
  --muted: #6a7682;
  --line: #e6ebf0;
  --line-strong: #d5dde5;
  --bg: #f3f5f7;
  --card: #ffffff;
  --danger: #c24747;
  --success: #1f8a63;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgba(26, 36, 48, .05);
  --shadow-soft: 0 1px 0 rgba(26,36,48,.03);
  --sidebar-w: 88px;
  --sub-w: 140px;
  --space: 20px;
  --space-lg: 28px;
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --display: "Cormorant Garamond", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-deep); text-decoration: none; }
a:hover { color: var(--primary); }

/* ===== Shell ===== */
.layout { display: flex; min-height: 100vh; }
.sider {
  display: flex;
  flex-shrink: 0;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 2px 0 16px rgba(26, 36, 48, .03);
}

.sidebar-primary {
  width: var(--sidebar-w);
  background: #fff;
  color: var(--text);
  padding: 16px 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-right: 1px solid var(--line);
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3aa297, var(--primary-deep));
  box-shadow: 0 6px 14px rgba(47,143,132,.22);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}
.brand-text {
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  font-weight: 500;
}
.brand-text b {
  display: block;
  color: var(--text);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
}

.side-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  padding: 0 2px 10px;
}
.side-nav .nav-link,
.side-nav .nav-parent {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: #5c6b78;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 10px;
  transition: .15s ease;
  position: relative;
}
.sub-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 6px;
}
.side-nav .nav-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.side-nav .nav-ico svg { width: 20px; height: 20px; fill: currentColor; }
.side-nav .nav-label { font-size: 11px; letter-spacing: .02em; font-weight: 500; }
.side-nav .nav-link:hover,
.side-nav .nav-parent:hover {
  background: #f4f7f8;
  color: var(--text);
}
.side-nav .nav-link.active,
.side-nav .nav-parent.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}
.side-nav .nav-link.active::before,
.side-nav .nav-parent.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}
.nav-parent .caret { display: none; }

/* Secondary — white, compact width */
.sidebar-sub {
  width: var(--sub-w);
  background: #fff;
  color: var(--text);
  padding: 16px 8px 14px;
  border-right: 1px solid var(--line);
  transition: width .2s ease, opacity .2s ease, padding .2s ease;
  overflow: hidden auto;
}
.sidebar-sub.is-empty {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
  border: 0;
}
.sub-panel { display: none; animation: fadeSlide .16s ease; }
.sub-panel.show { display: block; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: none; }
}
.sub-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 4px 8px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  line-height: 1.35;
}
.sub-title small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .06em;
}
.sidebar-sub a {
  display: block;
  padding: 9px 10px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #4a5866;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  transition: .12s ease;
  white-space: nowrap;
}
.sidebar-sub a::before { display: none; }
.sidebar-sub a:hover {
  background: #f4f7f8;
  color: var(--text);
}
.sidebar-sub a.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.topbar-kicker {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.topbar-heading {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text);
  line-height: 1.2;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  background: #f7f9fa;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.content {
  padding: 28px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.content > * { margin-top: 0; margin-bottom: 0; }
.content > .alert { margin-bottom: 0; }
.content > .section-title { margin: 8px 0 0; }

/* Surfaces */
.card, .table, .form-grid, .page-hero, .stat, .settings-nav, .tabs, .check-card, .channel-card, .toolbar {
  box-shadow: var(--shadow-soft);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 32px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47,143,132,.12), transparent 70%);
  pointer-events: none;
}
.page-hero h1 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: .02em;
}
.page-hero p { margin: 0; color: var(--muted); max-width: 720px; line-height: 1.75; font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  opacity: .85;
}
.stat .num {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  color: var(--primary-deep);
  letter-spacing: .01em;
  line-height: 1.15;
}
.stat .label { color: var(--muted); margin-top: 10px; font-size: 13px; font-weight: 500; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.inline, .inline-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 16px 18px;
  border-bottom: 1px solid #eef2f5;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.5;
}
.table th {
  background: #f7f9fa;
  color: #6a7682;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .04em;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #f8fbfb; }
.card .table {
  box-shadow: none;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card > .section-title + .table,
.card > .table { margin-top: 8px; }

/* Controls — more breathing room */
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-height: 42px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 110px; line-height: 1.6; resize: vertical; }
input[type="file"] {
  padding: 12px 14px;
  min-height: 46px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(47,143,132,.55);
  box-shadow: 0 0 0 3px rgba(47,143,132,.12);
}

.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  min-height: 40px;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13.5px;
  transition: .15s ease;
}
.btn:hover { border-color: #c3ced6; background: #f8fafb; }
.btn-primary {
  background: linear-gradient(180deg, #3aa297, var(--primary-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(47,143,132,.2);
}
.btn-primary:hover { filter: brightness(1.04); background: linear-gradient(180deg, #3aa297, var(--primary-deep)); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--text); }
.btn.ghost { background: var(--primary-soft); color: var(--primary-deep); border-color: transparent; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 600;
}
.tag.success { background: #d9f5e8; color: var(--success); }

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert.success { background: #e8f8f0; color: var(--success); border-color: #c8ebd8; }
.alert.danger, .alert.error { background: #fef1f1; color: var(--danger); border-color: #f3d0d0; }

.section-title {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
}
.form-grid {
  display: grid;
  grid-template-columns: 148px 1fr;
  column-gap: 20px;
  row-gap: 18px;
  max-width: 820px;
  background: var(--card);
  padding: 28px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: start;
}
.form-grid label { align-self: center; color: var(--muted); font-size: 13.5px; font-weight: 500; padding-top: 4px; }
.form-grid > input,
.form-grid > select,
.form-grid > textarea { width: 100%; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
}
.check { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.link { background: none; border: none; color: var(--primary-deep); cursor: pointer; padding: 0; font-weight: 500; }
.link.danger { color: var(--danger); }
.muted { color: var(--muted); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(47,143,132,.18), transparent 55%),
    radial-gradient(700px 380px at 90% 90%, rgba(184,149,106,.14), transparent 50%),
    linear-gradient(160deg, #f4f7f8 0%, #eef2f4 100%);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 32px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
}
.login-card .muted { margin: 0 0 4px; }
.login-card .btn-primary { margin-top: 8px; justify-content: center; padding: 12px; }

/* Settings / misc */
.msg-list { display: flex; flex-direction: column; gap: 12px; max-height: 360px; overflow: auto; }
.msg { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.msg.admin { background: #eaf6f4; }
.msg .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
}
.settings-nav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}
.settings-nav a {
  display: block;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}
.settings-nav a.active, .settings-nav a:hover { background: var(--primary-soft); color: var(--primary-deep); }
.settings-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
}
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.tabs a { padding: 10px 16px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.tabs a.active, .tabs a:hover { background: var(--primary-soft); color: var(--primary-deep); }

.form-grid.stack {
  grid-template-columns: 1fr;
  max-width: 880px;
  row-gap: 20px;
}
.form-grid.stack label {
  display: grid;
  gap: 10px;
  color: var(--text);
  align-self: stretch;
  padding-top: 0;
}
.form-grid.stack label input,
.form-grid.stack label select,
.form-grid.stack label textarea { width: 100%; }
.form-grid.stack .actions { display: flex; gap: 12px; }
.form-grid.stack .check { display: flex; align-items: center; gap: 10px; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.check-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.check-card a { margin-left: auto; font-size: 13px; white-space: nowrap; font-weight: 600; }
.check-dot { width: 9px; height: 9px; border-radius: 50%; background: #d1d5db; flex-shrink: 0; }
.check-card.ok .check-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(31,138,99,.12); }
.check-card.warn .check-dot { background: #e2a13a; box-shadow: 0 0 0 4px rgba(226,161,58,.14); }
.section-block { /* gap handled by .content */ }
.info-banner {
  background: #f3faf8;
  border: 1px solid #d4e8e3;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  color: #355;
  line-height: 1.75;
  font-size: 13.5px;
}
.info-banner ul { margin: 10px 0 0; padding-left: 20px; }
.info-banner li + li { margin-top: 6px; }
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.channel-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: #fff;
  display: grid;
  gap: 14px;
}
.channel-card.is-focus {
  border-color: rgba(47,143,132,.55);
  box-shadow: 0 0 0 3px rgba(47,143,132,.12);
}
.channel-portal-line {
  font-size: 13px;
  padding: 8px 10px;
  background: #f7faf9;
  border-radius: 8px;
}
.channel-portal-line a { font-weight: 600; }
.channel-card label {
  display: grid;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
.channel-card input { width: 100%; }
.channel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid #f0f3f5;
}
.channel-head .code {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 11px;
  font-weight: 700;
}
code { background: #eef4f5; padding: 2px 7px; border-radius: 6px; font-size: 12px; }

/* 对接网址导航 */
.table-wrap { overflow-x: auto; margin-top: 4px; }
.portal-table td { vertical-align: top; }
.portal-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--primary-deep);
  padding: 4px 0;
}
.portal-open:hover { color: var(--primary); text-decoration: underline; }
.portal-url {
  font-size: 12px;
  word-break: break-all;
  color: var(--muted);
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.portal-box {
  background: #f3faf8;
  border: 1px solid #d4e8e3;
  border-radius: 10px;
  padding: 14px;
}
.portal-box-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.portal-guide {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: #3d5552;
  line-height: 1.6;
}
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.5;
}
.field-hint a { font-weight: 600; }
.guide-steps {
  margin: 0;
  padding-left: 22px;
  line-height: 1.75;
  color: var(--text);
}
.guide-steps > li { margin-bottom: 12px; }
.guide-steps ul { margin: 8px 0 0; padding-left: 18px; }
.guide-steps code { font-size: 12px; }

/* pagination if any */
.pagination, .pager {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}

@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .stats, .detail-grid { grid-template-columns: 1fr 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  :root { --sidebar-w: 80px; --sub-w: 120px; }
  .content { padding: 22px 20px 40px; }
  .topbar { padding: 16px 20px; }
}
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sider {
    position: relative;
    height: auto;
    flex-direction: column;
    width: 100%;
    box-shadow: none;
  }
  .sidebar-primary {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 12px;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    flex-direction: row;
    padding: 0 10px 0 0;
    margin: 0;
    border: 0;
    min-width: max-content;
  }
  .brand-text { display: none; }
  .side-nav { flex-direction: row; overflow: visible; gap: 4px; padding: 0; }
  .side-nav .nav-link,
  .side-nav .nav-parent { min-width: 64px; padding: 8px 6px; }
  .side-nav .nav-link.active::before,
  .side-nav .nav-parent.active::before { display: none; }
  .sidebar-sub {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }
  .sidebar-sub.is-empty { width: 100%; height: 0; padding: 0; opacity: 0; border: 0; }
  .sidebar-sub a { white-space: normal; }
  .topbar { padding: 14px 16px; }
  .topbar-heading { font-size: 20px; }
  .content { padding: 16px; gap: 16px; }
  .stats, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid, .card, .settings-panel { padding: 18px; }
  .page-hero { padding: 18px; }
  .page-hero h1 { font-size: 22px; }
}
