:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --line: #2c3845;
  --text: #e7eef7;
  --muted: #93a4b8;
  --primary: #3d8bfd;
  --primary-hover: #5ca0ff;
  --danger: #f07178;
  --ok: #7fd99a;
  --input: #121820;
  --radius: 10px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 500px at 10% -10%, #1d3a5c55, transparent),
    radial-gradient(800px 400px at 100% 0%, #25403344, transparent),
    var(--bg);
  color: var(--text);
}

/* 登录 / 主界面切换：用 body.authed，避免 display 覆盖 hidden */
#login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

#app-view {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  grid-template-columns: 1fr;
  gap: 16px;
}

body.authed #login-view {
  display: none !important;
}

body.authed #app-view {
  display: grid !important;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: grid;
  gap: 16px;
}

.top, .row-between, .actions-bar, .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1, h2 { margin: 0 0 8px; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }

.muted, .hint { color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.hint code, pre code { color: #cfe3ff; }

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
}

.login-panel .primary {
  margin-top: 6px;
  width: 100%;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  font: inherit;
}
textarea {
  min-height: 96px;
  resize: vertical;
}
select { width: auto; min-width: 10rem; }
input:focus,
textarea:focus,
select:focus { border-color: var(--primary); }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.tab.active {
  background: color-mix(in srgb, var(--primary) 22%, var(--panel));
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
  color: var(--text);
}
.tab-panel {
  display: grid;
  gap: 16px;
}

.feedback-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 14px;
  min-height: 420px;
}
@media (max-width: 860px) {
  .feedback-layout {
    grid-template-columns: 1fr;
  }
}
.feedback-list-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  overflow: auto;
  max-height: 560px;
}
.feedback-list {
  display: flex;
  flex-direction: column;
}
.feedback-item {
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}
.feedback-item:hover { filter: none; background: #1c2733; }
.feedback-item.active {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}
.feedback-item .title {
  font-weight: 600;
  word-break: break-word;
}
.feedback-item .meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.feedback-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.feedback-msgs {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}
.msg {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #162029;
}
.msg.admin {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
}
.msg .who {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}
.msg .body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.feedback-reply {
  display: grid;
  gap: 8px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.pending_admin { color: #f0c674; border-color: #6a5530; }
.badge.pending_user { color: #7fd99a; border-color: #355a42; }
.badge.closed { color: #93a4b8; }

button {
  border: 1px solid var(--line);
  background: #243040;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}
button.primary:hover { background: var(--primary-hover); }
button.secondary { background: #2a3b52; }
button.ghost { background: transparent; }
button.danger {
  background: transparent;
  border-color: #5a2d33;
  color: var(--danger);
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 560; font-size: 0.85rem; }
td input { min-width: 120px; }
td.url-cell {
  max-width: 28rem;
  word-break: break-all;
  color: var(--muted);
  font-size: 0.9rem;
}
td.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

td.drag-cell {
  width: 2rem;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  text-align: center;
}
td.drag-cell:active { cursor: grabbing; }
.drag-handle {
  letter-spacing: -0.15em;
  font-size: 0.85rem;
  opacity: 0.7;
}
td.sort-cell {
  white-space: nowrap;
}
td.sort-cell .ghost {
  padding: 4px 8px;
  min-width: 2rem;
}
td.sort-cell .ghost:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}
tr.dragging {
  opacity: 0.55;
}
tr.drag-over {
  outline: 1px dashed color-mix(in srgb, var(--primary) 70%, transparent);
  outline-offset: -2px;
}

.status { color: var(--muted); min-height: 1.2em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.error { color: var(--danger); margin: 0; }

pre {
  margin: 0;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
