:root {
  --bg: #f0f4f8;
  --bg-accent: #e2eaf2;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5a6a7e;
  --line: #d5dee8;
  --brand: #0b6e99;
  --brand-dark: #085578;
  --ok: #1f7a4c;
  --ok-bg: #e8f6ee;
  --warn: #9a6b12;
  --warn-bg: #fff6e5;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --info: #175cd3;
  --info-bg: #eff4ff;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.06);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfe7f4 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #d9e8f5 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  min-height: 100vh;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 16px 60px;
  overflow-x: hidden;
}

header.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 22px;
}

header.top h1 {
  margin: 0 0 6px;
  font-size: 1.65rem;
  letter-spacing: 0.02em;
}

header.top p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.92rem;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel.active { display: block; }

.panel h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.panel .desc {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(11, 110, 153, 0.25);
  border-color: var(--brand);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary {
  background: #eef3f7;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f6f9fc;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.toast {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  display: none;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

#saveResult {
  display: block;
}

.toast.show { display: block; }
.toast.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b7e0c7; }
.toast.err { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c1bc; }
.toast.info { background: var(--info-bg); color: var(--info); border: 1px solid #c7d7fe; }
.toast.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d59a; }

.hint a { color: var(--brand); }

.table-wrap {
  margin-top: 16px;
  overflow-x: hidden; /* 不出现底部横向滚动条 */
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* 按比例分配列宽，整表铺满 */
}

th, td {
  padding: 8px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.84rem;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

th {
  background: #f7fafc;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

/* 列宽比例：整屏显示，不横向滑动 */
.col-id { width: 8%; }
.col-name { width: 10%; }
.content-cell { width: 30%; }
.col-status { width: 10%; white-space: nowrap; }
.col-reply { width: 9%; white-space: nowrap; }

.reply-none {
  color: var(--muted);
}

.reply-link {
  background: transparent;
  border: none;
  color: var(--danger);
  padding: 0;
  font-size: 0.86rem;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

.reply-link:hover { color: #8f1a12; }

.reply-popover {
  position: absolute;
  z-index: 1100;
  width: min(420px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(26, 35, 50, 0.18);
  padding: 12px 14px;
}

.reply-popover-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.92rem;
}

.reply-popover-body {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

.reply-popover-body a {
  color: var(--brand);
  word-break: break-all;
}
.col-region { width: 6%; white-space: nowrap; }
.col-time { width: 12%; }
.col-ops { width: 15%; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-0 { background: var(--ok-bg); color: var(--ok); }
.badge-1 { background: var(--warn-bg); color: var(--warn); }
.badge-2 { background: var(--info-bg); color: var(--info); }
.badge--1 { background: var(--danger-bg); color: var(--danger); }
.badge-other { background: #eee; color: #555; }

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.section-block {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.section-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-head .desc { margin-bottom: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar select,
.toolbar-input {
  width: auto;
  min-width: 120px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.toolbar-input {
  min-width: 180px;
  flex: 1;
}

.ops {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.ops .btn-sm {
  width: auto;
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 0.78rem;
}

#tplResult.show { display: block; margin-top: 0; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 50, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h3 { margin: 0; font-size: 1.1rem; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  padding: 0 6px;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  header.top h1 { font-size: 1.35rem; }
  .toolbar { width: 100%; }
  .toolbar-input { min-width: 0; width: 100%; }
}
