:root {
  --bg: #f0f3f2;
  --panel: #fff;
  --ink: #15201c;
  --muted: #66736d;
  --line: #dde4e0;
  --accent: #0f6b5c;
  --accent-hover: #0c574a;
  --danger: #b42318;
  --ok: #067647;
  --sidebar: #0f1c19;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 32, 29, 0.04), 0 8px 24px rgba(24, 32, 29, 0.06);
  --sidebar-w: 240px;
  --tap: 44px;
  --control-h: 40px;
  --control-radius: 8px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 40;
  background: var(--sidebar); color: #f5f2ea;
  padding: 10px 12px; align-items: center; gap: 10px;
  min-height: var(--tap);
}
.menu-btn {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 8px;
  background: rgba(255,255,255,0.08); color: inherit; font-size: 20px; cursor: pointer;
}
.mobile-bar-title { flex: 1; min-width: 0; }
.mobile-bar-title strong { display: block; font-size: 15px; }
.backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 45;
}
.backdrop.show { display: block; }

.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #152924 0%, var(--sidebar) 50%);
  color: #f5f2ea;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  z-index: 50;
}
.brand { font-size: 17px; font-weight: 700; margin: 0 8px 2px; }
.brand-sub { color: rgba(245,242,234,0.55); font-size: 12px; margin: 0 8px 12px; }
.nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nav::-webkit-scrollbar { width: 0; height: 0; }
.nav-group { margin-bottom: 10px; }
.nav-group:last-child { margin-bottom: 0; }
.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: none;
  color: rgba(245,242,234,0.42);
  padding: 0 12px 4px;
  user-select: none;
}
.nav a {
  display: block; color: rgba(245,242,234,0.82); padding: 8px 12px;
  border-radius: 8px; margin-bottom: 1px; text-decoration: none;
  min-height: 36px;
  line-height: 1.3;
}
.nav a:hover { background: rgba(255,255,255,0.07); }
.nav a.active { background: #1a3d35; color: #fff; font-weight: 600; }

.content { padding: 24px 28px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #e8eeec; color: var(--muted); margin-right: 4px; white-space: nowrap;
}
.badge.ok { background: #e3f5ea; color: var(--ok); }
.badge.warn { background: #fff4e5; color: #b54708; }
.badge.off { background: #f2e8e8; color: var(--danger); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f7faf8; }

.filter-bar { padding: 14px 16px; }
.filter-form,
.filter-bar > form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0 !important;
  min-width: 140px;
  flex: 0 1 180px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  gap: 0;
}
.filter-field.grow { flex: 1 1 220px; min-width: 180px; }
.filter-field.narrow { flex: 0 1 140px; min-width: 120px; max-width: 168px; }
.filter-bar label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0 !important;
  min-width: 140px;
  flex: 0 1 180px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.filter-bar label > input,
.filter-bar label > select,
.filter-field > input,
.filter-field > select {
  width: 100%;
  max-width: none;
  margin-top: 6px;
}
.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  min-width: auto;
}
.filter-actions button,
.filter-actions .btn {
  min-width: 72px;
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 16px;
  font-size: 14px;
}
.filter-inline { margin: 8px 0 12px; }
.filter-inline input { max-width: 320px; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.inline-form input,
.inline-form select {
  width: auto;
  max-width: none;
  flex: 1 1 160px;
  min-width: 140px;
}
.inline-form > button,
.inline-form > .btn { flex: 0 0 auto; }

.page-tabs { margin: 0 0 14px; gap: 8px; }
.page-tabs a { min-height: 38px; padding: 8px 14px; border-radius: 8px; }

.group-stat { padding-top: 14px; }
.group-stat-head {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  align-items: flex-start; margin-bottom: 10px;
}
.group-stat-sum {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  color: var(--muted); font-size: 13px;
}
.group-stat-sum b { color: var(--ink); font-size: 16px; }

table.compact { min-width: 0; }
table.compact th, table.compact td { padding: 8px 6px; }
.pre-cell { white-space: pre-line; font-size: 12px; max-width: 280px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { text-align: left; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #f7faf8; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.delta-pos { color: var(--ok); }
.delta-neg { color: var(--danger); }
.row-link { cursor: pointer; }
.row-link:hover td { background: #eef7f4; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 6px; line-height: 1.3; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  box-shadow: none;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select {
  height: var(--control-h);
  min-height: var(--control-h);
  padding: 0 12px;
  line-height: calc(var(--control-h) - 2px);
}
textarea {
  min-height: 96px;
  height: auto;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2366736d' d='M1 1.5L6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 34px;
  cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0 6px 0 0;
  vertical-align: middle;
  accent-color: var(--accent);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.12);
}
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.row-form > div { flex: 1; min-width: 140px; }
.row-form input, .row-form select { max-width: none; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: var(--accent); color: #fff;
  padding: 0 16px; border-radius: var(--control-radius); cursor: pointer; font: inherit;
  font-size: 14px; text-decoration: none;
  height: var(--control-h); min-height: var(--control-h);
  line-height: 1; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.ghost.danger, button.ghost.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: transparent;
}
.btn.ghost.danger:hover, button.ghost.danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.btn.danger, button.danger { background: var(--danger); }
.btn.small, button.small { padding: 0 10px; font-size: 12px; height: 32px; min-height: 32px; }
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.nowrap { white-space: nowrap; }

/* 群成员：操作列收紧，多群不撑高整行 */
.members-table td { vertical-align: top; }
.members-table .col-op {
  width: 128px;
  white-space: nowrap;
  vertical-align: middle;
}
.op-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.op-empty { font-size: 12px; }
.btn-text {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: none !important;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  height: auto;
  min-height: 0;
  cursor: pointer;
  text-decoration: none;
}
.btn-text:hover { text-decoration: underline; background: none !important; }
.btn-text.danger { color: var(--danger); }
.chat-list {
  max-width: 280px;
  line-height: 1.45;
  font-size: 13px;
}
.chat-list a { white-space: nowrap; }
.chat-sep { color: var(--muted); margin: 0 2px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #e7f4f0; color: var(--accent);
}
.badge.off { background: #f4e8e7; color: var(--danger); }
.badge.warn { background: #fff4e5; color: #b54708; }
.error {
  background: #fef3f2; color: var(--danger); border: 1px solid #fecdca;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}
.okmsg {
  background: #ecfdf3; color: var(--ok); border: 1px solid #abefc6;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(15,107,92,0.12), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 28px 22px;
}
.login-card input { max-width: none; }
.login-card label { margin: 12px 0 6px; }
.login-card label:first-of-type { margin-top: 0; }
.block { width: 100%; height: var(--control-h); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a {
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.detail-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.detail-tabs a:hover { background: #eef5f2; text-decoration: none; color: var(--ink); }
.detail-tabs a.active {
  background: var(--accent);
  color: #fff;
}
.detail-tabs .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.detail-tabs a:not(.active) .tab-count {
  background: #e7f0ed;
  color: var(--accent);
}
.tab-panel[hidden] { display: none !important; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px 12px;
}
.settings-grid .check { margin: 4px 0; }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 28, 25, 0.46);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(480px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(15, 28, 25, 0.22);
  border: 1px solid var(--line);
  max-height: min(88vh, 720px);
  overflow: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close {
  width: 36px; height: 36px;
  border: 0; background: transparent;
  color: var(--muted); font-size: 22px; cursor: pointer;
  border-radius: 8px;
  line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-body { padding: 14px 18px 18px; }
.modal-body .stack-form { display: flex; flex-direction: column; gap: 10px; }
.modal-body .stack-form label { display: block; }
.modal-body .stack-form input[type="text"],
.modal-body .stack-form input[type="password"],
.modal-body .stack-form input:not([type]) {
  width: 100%;
  max-width: none;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  .mobile-bar { display: flex; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 280px);
    transform: translateX(-105%); transition: transform 0.2s ease;
    height: 100vh; padding-top: 16px;
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px 14px 28px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 20px; }
  table { min-width: 0; font-size: 13px; }
  .hide-sm { display: none; }
  .filter-field,
  .filter-bar label { flex: 1 1 100%; min-width: 0; max-width: none; }
  .filter-actions { width: 100%; }
}
