:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --line: #d9e1ec;
  --text: #17202c;
  --muted: #667085;
  --accent: #0f62fe;
  --accent-dark: #004bd6;
  --danger: #d92d20;
  --warn: #b54708;
  --ok: #067647;
  --shadow: 0 14px 34px rgba(16, 24, 40, 0.08);
  --soft-shadow: 0 8px 20px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #f8fbff 0, #f3f6fb 260px),
    var(--bg);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  background: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button.secondary,
.panel-head button,
.table-tools button {
  background: #edf2f7;
  color: var(--text);
}

button.secondary:hover,
.panel-head button:hover,
.table-tools button:hover {
  background: #dfe7f2;
}

button.primary-action {
  min-width: 124px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15, 98, 254, 0.24);
}

button.primary-action:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 22px rgba(15, 98, 254, 0.30);
}

.panel-head button.primary-action {
  background: var(--accent);
  color: #fff;
}

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

button.link-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
  box-shadow: none;
  font-weight: 700;
  text-align: left;
}

button.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label span,
.field-title {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 119, 255, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(6, 118, 71, 0.10), transparent 30%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
  display: grid;
  gap: 16px;
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
}

.login-panel p,
.login-panel small {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.32), transparent 28%),
    linear-gradient(135deg, #0f62fe 0, #143c8f 55%, #101828 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 98, 254, 0.26);
}

.brand-mark svg {
  width: 31px;
  height: 31px;
  display: block;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  background:
    linear-gradient(180deg, #111827 0, #172033 100%);
  color: #fff;
  padding: 20px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  box-shadow: 8px 0 24px rgba(16, 24, 40, 0.10);
}

.product {
  display: flex;
  gap: 12px;
  align-items: center;
}

.product strong {
  display: block;
  font-size: 18px;
}

.product span {
  display: block;
  color: #9ca3af;
  font-size: 12px;
}

nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav-item {
  background: transparent;
  color: #d1d5db;
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: currentColor;
  opacity: 0.82;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  background: #253246;
  color: #fff;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item.active svg {
  opacity: 1;
}

.main {
  min-width: 0;
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

.topbar {
  min-height: 74px;
  padding: 4px 2px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.user-menu span {
  max-width: 160px;
  min-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 18px 16px;
  box-shadow: var(--soft-shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.content-grid,
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.split {
  grid-template-columns: minmax(320px, 420px) 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  box-shadow: var(--soft-shadow);
}

.panel-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.list,
.stat-list,
.cards,
.form-panel {
  padding: 16px;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.list-item,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.list-item:hover,
.card:hover {
  border-color: #b9c7dc;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.06);
  transform: translateY(-1px);
}

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

.list-item strong,
.card strong {
  display: block;
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.compact-cards {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.wechat-bind-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 14px;
}

.wechat-bind-box strong {
  display: block;
  margin-bottom: 4px;
}

.wechat-bind-box p,
.wechat-qr-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.wechat-qr-box {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #b9c7dc;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.wechat-qr-box img {
  width: 164px;
  height: 164px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wechat-qr-box a {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.inline-form button {
  min-width: 96px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #eef2f7;
  color: #344054;
}

.pill.critical {
  background: #fee4e2;
  color: #b42318;
}

.pill.major {
  background: #ffead5;
  color: #b54708;
}

.pill.warning {
  background: #fef0c7;
  color: #93370d;
}

.pill.info {
  background: #d1e9ff;
  color: #175cd3;
}

.pill.open {
  background: #fee4e2;
  color: #b42318;
}

.pill.ack {
  background: #fef0c7;
  color: #93370d;
}

.pill.closed,
.pill.enabled {
  background: #dcfae6;
  color: #067647;
}

.pill.disabled {
  background: #f2f4f7;
  color: #667085;
}

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

.stat-row {
  display: grid;
  grid-template-columns: 90px 1fr 38px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 8px;
  border-radius: 99px;
  background: #e4e7ec;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.table-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.table-tools select {
  width: 160px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 600;
}

tbody tr:hover {
  background: #f8fbff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.check-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-list input {
  width: auto;
}

dialog {
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.modal-card {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  background: var(--panel);
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

.compact-modal {
  width: min(460px, calc(100vw - 28px));
}

.wide-modal {
  width: min(860px, calc(100vw - 28px));
}

.alert-detail-body {
  display: grid;
  gap: 16px;
  padding-bottom: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid div,
.kv-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 11px 12px;
  min-width: 0;
}

.detail-grid span,
.kv-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.detail-grid strong,
.kv-list strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-block {
  display: grid;
  gap: 8px;
}

.detail-block h4 {
  margin: 0;
  font-size: 14px;
}

.detail-block p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

.media-list,
.kv-list {
  display: grid;
  gap: 8px;
}

.media-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.media-list a {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  text-decoration: none;
}

.media-list a:hover {
  border-color: var(--accent);
}

.media-list span,
.media-list small {
  color: var(--muted);
  font-size: 12px;
}

.push-results {
  display: grid;
  gap: 8px;
}

.push-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #98a2b3;
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
}

.push-result.success {
  border-left-color: var(--ok);
}

.push-result.failed {
  border-left-color: var(--danger);
}

.push-result strong {
  display: block;
}

.push-result span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.push-result p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.modal-actions button:first-child {
  background: #edf2f7;
  color: var(--text);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #101828;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 36px));
  z-index: 10;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-rows: auto auto auto;
  }

  nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    padding: 9px 6px;
    gap: 6px;
  }

  .nav-item svg {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

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

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-actions button {
    flex: 1;
  }

  .user-menu {
    width: 100%;
    padding-left: 0;
    border-left: 0;
  }

  .user-menu span {
    text-align: left;
    flex: 1 1 100%;
    max-width: none;
  }

  .user-menu button {
    flex: 1;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    gap: 10px;
  }

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

  .push-result {
    grid-template-columns: 1fr;
  }

  .wechat-bind-box,
  .wechat-qr-box {
    align-items: stretch;
    flex-direction: column;
  }

  .wechat-qr-box img {
    width: 100%;
    height: auto;
    max-width: 220px;
  }

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