:root {
  color-scheme: light dark;
  --bg: #f4f5f2;
  --panel: #fffefa;
  --ink: #1d231f;
  --muted: #66706a;
  --line: #d8dcd6;
  --accent: #1f7a5a;
  --danger: #a33b2b;
  --warn: #9a6a1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { display: flex; gap: .8rem; align-items: baseline; }
.brand span { color: var(--muted); font-size: .85rem; }

main { max-width: 78rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

h1 { margin: 0 0 .5rem; font-size: 1.4rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
}

.login { max-width: 34rem; margin: 2rem auto; }
.login p { color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  font: inherit;
}

textarea { resize: vertical; }

label { display: block; font-weight: 600; }
.login label { margin: 1rem 0 .4rem; }

button {
  padding: .55rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled { opacity: .5; cursor: progress; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.danger { background: var(--danger); }

.login form button { margin-top: 1rem; }

.toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar input { max-width: 22rem; }
.count { color: var(--muted); font-size: .9rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.list { padding: .5rem; max-height: 72vh; overflow: auto; }

.tabs { display: flex; gap: .35rem; padding: .25rem .25rem .55rem; margin-bottom: .5rem; border-bottom: 1px solid var(--line); }

.tab { flex: 1; padding: .45rem .6rem; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; }
.tab.active { background: #eef7f1; color: var(--accent); }

.staged-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .35rem .25rem .65rem;
  margin-bottom: .4rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}

.staged-bar button { padding: .4rem .7rem; font-size: .85rem; }

.list .item {
  display: block;
  width: 100%;
  margin-bottom: .4rem;
  padding: .7rem .8rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-weight: 400;
}

.list .item:hover { border-color: var(--line); }
.list button.item.active { border-color: var(--accent); background: #eef7f1; }
.list .item button.small { margin-top: .4rem; padding: .25rem .6rem; font-size: .78rem; }
.list .item-head { display: flex; justify-content: space-between; gap: .5rem; }
.list .item-head strong { font-size: .95rem; }
.list .item-meta { color: var(--muted); font-size: .82rem; }
.list .flags { color: var(--warn); font-size: .78rem; }

.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

.summary {
  padding: .8rem 1rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f0f6f2;
  color: var(--muted);
  font-size: .9rem;
  white-space: pre-wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .9rem;
  margin-bottom: .9rem;
}

.grid label { font-size: .88rem; color: var(--muted); }
.grid label input, .grid label select { margin-top: .3rem; font-weight: 400; color: var(--ink); }

.field { display: block; font-size: .88rem; color: var(--muted); font-weight: 600; }
.field-title { display: block; }

.combo { position: relative; margin-top: .3rem; font-weight: 400; color: var(--ink); }
.combo input { margin: 0; }
.combo-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 17rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.combo-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  padding: .4rem .65rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}
.combo-item:hover, .combo-item.active { background: #eef7f1; }
.combo-label { font-size: .92rem; color: var(--ink); }
.combo-sub { font-size: .78rem; color: var(--muted); }
.combo-empty { padding: .5rem .65rem; font-size: .85rem; color: var(--muted); }

.preview {
  margin-top: .4rem;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  font-size: .9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview:empty { display: none; }
.preview mark { border-radius: 3px; padding: 0 2px; }
.preview mark.hit-hard { background: #f6c6bd; color: #6b1d10; }
.preview mark.hit-soft { background: #f6e6b8; color: #5f4708; }

.similar {
  margin-bottom: 1.1rem;
  padding: .7rem .9rem;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  background: #fdf6e3;
  font-size: .88rem;
}
.similar .similar-title { font-weight: 600; margin-bottom: .3rem; }
.similar ul { margin: 0; padding-left: 1.1rem; }
.similar li { margin-bottom: .25rem; }
.similar .similar-note { color: var(--muted); margin-top: .35rem; }

.checks.vertical { flex-direction: column; gap: .45rem; }
.checks.vertical label { display: flex; gap: .45rem; align-items: flex-start; font-weight: 400; color: var(--ink); }
.checks.vertical input { width: auto; margin-top: .3rem; }

.status.blocked { color: var(--danger); font-weight: 600; }
.status.warn { color: var(--warn); }

#reject-panel { margin-top: 1rem; }
#reject-panel label { display: block; margin-bottom: .7rem; font-size: .88rem; color: var(--muted); font-weight: 600; }
#reject-panel select, #reject-panel input { margin-top: .3rem; font-weight: 400; color: var(--ink); }

.detail > form > label { margin-bottom: 1rem; font-size: .88rem; color: var(--muted); }
.detail textarea { margin-top: .3rem; font-weight: 400; color: var(--ink); }

fieldset {
  margin: 0 0 1.1rem;
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}

legend { padding: 0 .35rem; color: var(--muted); font-size: .85rem; }

.checks { display: flex; flex-wrap: wrap; gap: .6rem 1rem; }
.checks label { display: flex; gap: .35rem; align-items: center; font-weight: 400; }
.checks input { width: auto; }

.subpanel { margin-bottom: .9rem; padding: .8rem; border: 1px dashed var(--line); border-radius: 9px; }

.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }

.status { min-height: 1.4rem; color: var(--muted); font-size: .88rem; }
.status.error { color: var(--danger); }

@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }
  .list { max-height: 16rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816;
    --panel: #1e2320;
    --ink: #e9ece7;
    --muted: #a5ada6;
    --line: #333a35;
    --accent: #4bbd8d;
    --danger: #e07a67;
    --warn: #d8ad63;
  }
  .summary { background: #23302a; }
  .list button.item.active { background: #233a2e; }
  .tab.active { background: #233a2e; }
  .combo-item:hover, .combo-item.active { background: #233a2e; }
}
