/* ================= 房修整理台 · 黑白灰主题 ================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg0: #050505;
  --bg1: #0d0d0d;
  --bg2: #1a1a1a;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.32);
  --text: #f2f2f2;
  --muted: rgba(242, 242, 242, 0.55);

  --accent: #e5e5e5;
  --accent-2: #9a9a9a;

  --radius: 16px;
  --radius-sm: 10px;
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, #262626, transparent 55%),
    radial-gradient(circle at 92% 100%, #1f1f1f, transparent 55%),
    linear-gradient(160deg, #0a0a0a, #141414 70%);
  background-attachment: fixed;
}

[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.78rem; margin: 0.4rem 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.8rem; }

.brand__logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  font-size: 1.2rem; font-weight: 800;
  color: #111;
  background: linear-gradient(135deg, #f2f2f2, #8f8f8f);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
}

.brand__text h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand__text p { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--muted); }

.topbar__actions { display: flex; align-items: flex-end; gap: 0.7rem; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field span { font-size: 0.72rem; color: var(--muted); }

.field input, .field select {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}
.field select option { background: #161616; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit;
  font-weight: 650;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1.05rem;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn--sm { padding: 0.42rem 0.75rem; font-size: 0.82rem; font-weight: 600; }

.btn--primary {
  color: #111;
  background: linear-gradient(120deg, #f5f5f5, #bdbdbd);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--ghost {
  background: var(--panel-2);
  border-color: var(--border);
}
.btn--ghost:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.14); }

.btn--danger {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
  color: #f2f2f2;
}
.btn--danger:hover { background: rgba(255, 255, 255, 0.18); }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: none; border-radius: 9px;
  background: transparent; color: var(--muted);
  cursor: pointer; font-size: 0.85rem;
  transition: background 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.icon-btn--sm { width: 26px; height: 26px; font-size: 0.72rem; }

/* ---------- 布局 ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 1.1rem;
  padding: 1.1rem 1.4rem 2rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem;
  backdrop-filter: blur(16px);
  min-width: 0;
}

.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.85rem;
}
.panel__head h2 { margin: 0; font-size: 0.98rem; font-weight: 700; display: flex; align-items: center; gap: 0.45rem; }
.panel__head em {
  font-style: normal; font-size: 0.72rem; width: 20px; height: 20px;
  display: grid; place-items: center; border-radius: 50%;
  background: #e5e5e5; color: #111;
}
.panel__tools { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.panel__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; margin-top: 0.85rem;
}

/* ---------- 输入区 ---------- */
#raw-input {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
}
#raw-input::placeholder { color: rgba(242, 242, 242, 0.35); }
#raw-input:focus, .text-input:focus, .rules-input:focus, .col-name:focus {
  outline: none; border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
}

.progress { margin-top: 0.7rem; }
.progress__bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.progress__bar i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #8f8f8f, #f2f2f2); transition: width 0.25s ease; }
.progress span { display: inline-block; margin-top: 0.35rem; }

/* ---------- 表格 ---------- */
.grid-wrap { overflow: auto; max-height: 62vh; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.85rem; }

.grid__th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; white-space: nowrap;
  padding: 0.55rem 0.7rem;
  background: #1c1c1c;
  border-bottom: 1px solid var(--border);
}
.grid__th--del { width: 36px; }
.grid__col-name { font-weight: 700; margin-bottom: 0.2rem; }
.grid__col-src {
  font-size: 0.62rem; font-weight: 600; padding: 0.08rem 0.4rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: var(--muted);
}
.src--index { color: #eaeaea; } .src--date { color: #cfcfcf; }
.src--extract { color: #bdbdbd; } .src--judge { color: #a6a6a6; }
.src--manual { color: #8c8c8c; }

.grid__cell {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  vertical-align: top;
  min-width: 72px;
  max-width: 320px;
  word-break: break-word;
  white-space: pre-wrap;
  outline: none;
}
.grid tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
.grid__cell[contenteditable="true"]:focus {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 2px #cfcfcf;
}
.grid__cell--del { width: 36px; text-align: center; padding: 0.3rem; }

/* 需核对：无彩色下用「反白高亮」表示，最醒目 */
.grid__cell.is-error {
  background: #e6e6e6;
  color: #111;
  font-weight: 600;
  box-shadow: inset 0 0 0 2px #ffffff;
}

.empty { text-align: center; color: var(--muted); padding: 2.4rem 1rem; margin: 0; font-size: 0.9rem; }

/* ---------- 抽屉 ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer__mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px); }
.drawer__panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(94vw, 440px);
  display: flex; flex-direction: column;
  background: #121212;
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.65);
  animation: slideIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer__head, .drawer__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.drawer__foot { border-bottom: none; border-top: 1px solid var(--border); }
.drawer__head h2 { margin: 0; font-size: 1rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 1.1rem; }
.drawer__body h3 { font-size: 0.82rem; color: var(--muted); margin: 1.2rem 0 0.5rem; letter-spacing: 0.05em; }
.drawer__body h3:first-child { margin-top: 0; }

.col-editor { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.6rem; }
.col-row { display: grid; grid-template-columns: 1fr 110px 30px; gap: 0.4rem; align-items: center; }

.text-input, .col-name, .rules-input {
  width: 100%; font: inherit; font-size: 0.85rem; color: var(--text);
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
  border-radius: 9px; padding: 0.5rem 0.6rem;
}
.col-source { font: inherit; font-size: 0.78rem; color: var(--text); background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border); border-radius: 9px; padding: 0.45rem 0.4rem; }
.col-source option { background: #161616; }
.rules-input { min-height: 190px; resize: vertical; line-height: 1.55; font-size: 0.8rem; }

.switch { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.85rem; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: #d4d4d4; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; padding: 0.6rem 1.1rem; border-radius: 999px;
  background: rgba(24, 24, 24, 0.96); border: 1px solid var(--border);
  color: var(--text); font-size: 0.85rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.2s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; padding: 0.9rem; }
  #raw-input { min-height: 200px; }
  .grid-wrap { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
