:root {
  --blue: #4a76c9;
  --blue-dark: #3d63ab;
  --blue-darker: #37507f;
  --sidebar-bg: #2b2f3a;
  --sidebar-hover: #363b48;
  --sidebar-text: #b7bdc9;
  --red: #c0392b;
  --red-dark: #a5301f;
  --border: #e3e6ea;
  --row-hover: #f5f7fa;
  --row-selected: #e3ecfb;
  --text: #2c313a;
  --muted: #8992a1;
  --green: #3fa15e;
  --amber: #c98a1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #fff;
  font-size: 14px;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: 48px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title { font-weight: 700; font-size: 15px; }
.source-pill {
  background: rgba(255,255,255,0.16);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-family: "SF Mono", Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.actions { display: flex; gap: 6px; }
.actions button {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  padding: 6px 11px;
  border-radius: 4px;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.12s ease;
}
.actions button:hover { background: rgba(255,255,255,0.26); }
.actions button.danger-hint:hover { background: rgba(192,57,43,0.85); }

.body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 210px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 10px 0;
}
.sidebar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  padding: 4px 16px 8px;
}
.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  margin: 0 6px;
  border-radius: 4px;
}
.filter-row:hover { background: var(--sidebar-hover); }
.filter-row.active { background: var(--blue-darker); color: #fff; }
.filter-row .count { color: #7d8496; font-size: 12px; }
.filter-row.active .count { color: rgba(255,255,255,0.8); }

.content { flex: 1; overflow: auto; background: #fff; }

.file-table { width: 100%; border-collapse: collapse; }
.file-table thead th {
  position: sticky; top: 0; background: #fff;
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.file-table thead th.col-check { width: 34px; }
.file-table tbody tr { border-bottom: 1px solid var(--border); }
.file-table tbody tr:hover { background: var(--row-hover); }
.file-table tbody tr.archived-row { opacity: 0.55; }
.file-table td { padding: 9px 12px; color: var(--text); vertical-align: middle; }

.name-cell { display: flex; flex-direction: column; cursor: pointer; }
.name-cell .fname { color: var(--blue-dark); font-weight: 600; }
.name-cell .fname:hover { text-decoration: underline; }
.name-cell .fid { color: var(--muted); font-size: 11.5px; font-family: "SF Mono", Consolas, monospace; }

.match-cell { color: var(--muted); font-size: 12.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.requires-cell { font-size: 12px; color: var(--muted); }
.req-error { color: var(--red); font-weight: 600; cursor: help; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.status-badge.enabled { background: #e5f5ea; color: var(--green); }
.status-badge.disabled { background: #f0f1f4; color: var(--muted); }
.status-badge.archived { background: #fbeee0; color: var(--amber); }

.row-actions { display: flex; gap: 4px; }
.row-actions button {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; font-size: 12px; cursor: pointer; color: var(--text);
}
.row-actions button:hover { background: var(--row-hover); }
.row-actions button.danger { color: var(--red); border-color: #f0c9c3; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state p { margin: 4px 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,34,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 6px; width: 380px; max-width: calc(100vw - 40px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.25); overflow: hidden;
}
.modal-wide { width: 700px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.preview-meta { font-size: 12px; color: var(--muted); }
.modal-head .close { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }

.file-drop {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1.5px dashed var(--border); border-radius: 6px; background: #fafbfc;
}
.file-drop.drag-over { border-color: var(--blue); background: #eef4ff; }
.file-drop-text { font-size: 13px; color: var(--muted); }

.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.text-input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px;
}
.text-input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

.btn { padding: 9px 18px; border: none; border-radius: 4px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-dark); }

.editor {
  width: 100%; min-height: 340px; border: 1px solid var(--border); border-radius: 4px;
  padding: 12px; font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 12.5px;
  resize: vertical; margin-top: 12px;
}
.editor.small-editor { min-height: 140px; margin-top: 0; }

.warning-box {
  margin-top: 10px; background: #fdf1ec; border: 1px solid #f3d2c1; color: #9a4a1f;
  padding: 10px 12px; border-radius: 4px; font-size: 12.5px;
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #2c313a; color: #fff; padding: 10px 18px; border-radius: 6px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toast.error { background: var(--red); }

.muted { color: var(--muted); }

@media (max-width: 760px) {
  .sidebar { display: none; }
  .col-requires { display: none; }
}
