:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --soft: #eef4f2;
  --ink: #18201f;
  --muted: #657370;
  --line: #dbe3e1;
  --teal: #087264;
  --teal-dark: #055b50;
  --red: #cf5f4b;
  --blue: #2d64a5;
  --shadow: 0 16px 34px rgba(28, 37, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 4px;
}

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

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.brand h1 {
  font-size: 24px;
}

.brand p,
.panel-title p,
.panel-title span,
.region-card small,
.topic-card small,
.topic-card p,
.detail-head p,
.detail-head span,
.batch-head span,
.modal-note,
.field span,
.batch-note {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 14px;
}

.top-actions {
  display: grid;
  grid-template-columns: minmax(260px, 430px) auto auto auto auto auto;
  gap: 10px;
  align-items: center;
  flex: 1;
  justify-content: end;
}

.search-box input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-box input,
.field input,
.field select {
  min-height: 42px;
  padding: 0 13px;
}

.field textarea {
  min-height: 168px;
  padding: 11px 13px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 114, 100, 0.14);
}

.primary-button,
.soft-button,
.icon-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.soft-button {
  min-height: 38px;
  padding: 0 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.soft-button.small,
.copy-button {
  min-height: 30px;
  font-size: 13px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-color: var(--line);
  background: #fff;
  font-size: 20px;
}

.notice-bar {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #f0d8a8;
  border-radius: 8px;
  background: #fff7e7;
  color: #6d4810;
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: 260px 340px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.content-grid.detail-mode {
  grid-template-columns: 170px 220px minmax(0, 1fr);
}

.panel {
  min-width: 0;
  min-height: calc(100vh - 112px);
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title h2 {
  font-size: 18px;
}

.region-list,
.topic-list,
.batch-list,
.link-list {
  display: grid;
  gap: 9px;
}

.region-card,
.topic-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.region-card span,
.topic-card strong {
  font-size: 16px;
  font-weight: 800;
}

.region-card.active,
.topic-card.active {
  border-color: var(--teal);
  background: #eef8f5;
  box-shadow: 0 0 0 3px rgba(8, 114, 100, 0.1);
}

.region-card.muted {
  opacity: 0.52;
}

.dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 8px;
  background: #ffe8df;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.topic-card div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-card p {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--muted);
  text-align: center;
}

.detail-content {
  display: grid;
  gap: 14px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.detail-head h2 {
  margin: 4px 0;
  font-size: 26px;
}

.batch-card {
  display: grid;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.batch-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.batch-head div {
  display: grid;
  gap: 4px;
}

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

.batch-note {
  padding: 12px 13px;
  border: 1px solid #f2d196;
  border-left: 5px solid #d38824;
  border-radius: 8px;
  background: #fff7e6;
  color: #663b09;
  font-weight: 800;
  line-height: 1.5;
}

.batch-note strong {
  margin-right: 8px;
  color: #9a570b;
}

.link-row {
  display: grid;
  grid-template-columns: 34px 104px 56px minmax(56px, 76px) minmax(150px, 210px) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #edf1f0;
  border-radius: 8px;
  background: #fbfcfc;
}

.link-row span {
  color: var(--muted);
  text-align: center;
}

.link-row a {
  color: var(--teal);
  font-weight: 900;
  text-decoration: none;
}

.copy-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.admin-link-actions {
  min-width: 0;
}

.tiny {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.link-row code {
  min-width: 0;
  color: #42524f;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.link-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.link-meta small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.meta-error {
  color: var(--red) !important;
}

.traffic-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4f2;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.traffic-tag.高流量 {
  background: #ffe8d7;
  color: #b54614;
}

.traffic-tag.中等流量 {
  background: #eef2ff;
  color: #2d58a7;
}

.traffic-tag.低流量 {
  background: #edf7ef;
  color: #2f7a43;
}

.traffic-tag.待更新 {
  background: #f2f4f4;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 17, 0.44);
}

.modal-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 13px;
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.small-card {
  width: min(360px, 100%);
}

.admin-card {
  width: min(860px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-note {
  margin-top: 4px;
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 13px;
  font-weight: 800;
}

.field-group {
  display: grid;
  gap: 13px;
}

.mode-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  border: 0;
}

.mode-field legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mode-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  font-weight: 800;
}

.mode-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.selection-note {
  color: var(--muted);
  font-size: 13px;
}

.recent-list {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.recent-list button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--ink);
}

.form-message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.form-message.ok {
  color: var(--teal);
}

.user-list {
  display: grid;
  gap: 10px;
}

.settings-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.settings-head p {
  color: var(--muted);
  font-size: 13px;
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-weight: 800;
  white-space: nowrap;
}

.switch-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

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

.danger-lite {
  color: #a64200;
  border-color: #f0c7a4;
  background: #fff7ed;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-row strong {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.user-row strong span,
.user-row p {
  color: var(--muted);
  font-size: 13px;
}

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

.delay-select {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

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

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .topbar,
  .top-actions {
    display: grid;
    justify-content: stretch;
  }

  .top-actions {
    grid-template-columns: 1fr 1fr;
  }

  .search-box {
    grid-column: 1 / -1;
  }

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

  .content-grid.detail-mode {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .top-actions,
  .detail-head,
  .batch-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .link-row {
    grid-template-columns: 28px 1fr 54px;
  }

  .link-meta,
  .link-row code {
    grid-column: 1 / -1;
  }

  .settings-head,
  .settings-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
}
