:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #2d2a26;
  --muted: #8a857e;
  --border: #e6e1d6;
  --accent: #1f5c4d;
  --accent-soft: #e8f2ee;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #9a6b00;
  --warn-soft: #fdf4e3;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(45, 42, 38, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e7efe9 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #efe8da 0%, transparent 55%),
    var(--bg);
}

.login__card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 38px 34px 30px;
}

.login__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.login__brand h1 { font-size: 24px; letter-spacing: -0.02em; color: var(--accent); }
.login__brand p { font-size: 12.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.logo {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--accent);
  color: #f4f1ea;
  font-weight: 700; font-size: 22px;
  font-family: Georgia, serif;
  flex: 0 0 auto;
}

.login__foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 通用控件 ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; color: #4a463f; margin-bottom: 6px; }
.field input, .field select, .field textarea,
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 92, 77, 0.12);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #174a3e; }
.btn--ghost { border-color: var(--border); color: #4a463f; background: var(--surface); }
.btn--ghost:hover { border-color: #cfc8bb; background: var(--surface-2); }
.btn--danger { color: var(--danger); border-color: #f0cdc9; background: #fff; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

.msg { display: none; font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.msg.is-on { display: block; }
.msg.is-err { background: var(--danger-soft); color: var(--danger); }
.msg.is-ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- 主框架 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 26px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand > div { display: flex; align-items: center; gap: 10px; }
.topbar__brand strong { font-size: 17px; letter-spacing: -0.01em; color: var(--accent); }
.topbar__brand .logo { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.chip--muted { background: #f1eee7; color: var(--muted); font-weight: 500; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13.5px; font-weight: 500;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }

.msg--page { margin-bottom: 16px; }

.panel { display: none; }
.panel.is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.panel__head h2 { font-size: 18px; letter-spacing: -0.01em; }

.grid { display: grid; gap: 14px; margin-bottom: 18px; }
#serviceGrid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid--2 { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 0 rgba(45, 42, 38, 0.02);
}
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 14px; }
.card--flush { padding: 0; overflow: hidden; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat__label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat__value { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.stat__hint { font-size: 12px; color: var(--muted); margin-top: 6px; word-break: break-all; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot--ok { background: #2f8f6b; box-shadow: 0 0 0 3px rgba(47, 143, 107, 0.14); }
.dot--bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12); }
.dot--warn { background: #c98a00; box-shadow: 0 0 0 3px rgba(201, 138, 0, 0.14); }

.checks { list-style: none; display: grid; gap: 10px; }
.checks li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 9px; background: var(--surface-2);
  border: 1px solid #efeae0;
}
.checks b { font-size: 13px; font-weight: 600; display: block; }
.checks small { color: var(--muted); font-size: 12px; word-break: break-all; }
.checks .is-bad b { color: var(--danger); }

.records { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 12.5px; }
.records dt { color: var(--muted); }
.records dd { margin: 0; word-break: break-all; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid #f0ece3; vertical-align: middle; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fdfcf9; }
.table .right { text-align: right; }
.table td.mono, .mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; }
.table .muted { color: var(--muted); }
.table td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table--logs td { font-size: 12.5px; }
.table--logs .detail { color: #4a463f; }

.badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge--auth { background: #eef1f8; color: #3f568f; }
.badge--received { background: var(--accent-soft); color: var(--accent); }
.badge--sent { background: var(--warn-soft); color: var(--warn); }
.badge--fail { background: var(--danger-soft); color: var(--danger); }

.note { font-size: 12px; color: var(--muted); margin-top: 12px; }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg {
  border: 1px solid var(--border); background: var(--surface);
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; color: #4a463f;
}
.seg.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.input--search { width: 210px; padding: 7px 11px; }

/* ---------- 弹窗 ---------- */
.dialog {
  border: none; border-radius: 14px; padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(45, 42, 38, 0.22);
  background: var(--surface);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(45, 42, 38, 0.35); backdrop-filter: blur(2px); }
.dialog form { padding: 24px 24px 20px; }
.dialog h3 { font-size: 17px; margin-bottom: 16px; }
.dialog__body .field:last-child { margin-bottom: 4px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .grid--2 { grid-template-columns: 1fr; }
  .main { padding: 18px 14px 50px; }
  .table th, .table td { padding: 9px 12px; }
  .input--search { width: 100%; }
}
