*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #fff;
  --fg: #111;
  --muted: #666;
  --line: #d7d7d7;
  --soft: #f6f6f6;
  --danger: #b00020;
  --ok: #146c2e;
  --info: #1f5fbf;
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--fg);
  background: var(--bg);
}

body {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

header {
  display: grid;
  gap: 6px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--fg);
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

header p {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

code {
  padding: 1px 4px;
  color: var(--fg);
  background: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

nav .sep {
  width: 1px;
  height: 24px;
  margin: 0 2px;
  overflow: hidden;
  color: transparent;
  background: var(--line);
}

button,
input,
select {
  font: inherit;
}

button {
  height: 32px;
  padding: 0 12px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--fg);
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  color: var(--bg);
  background: var(--fg);
  outline: 0;
}

button:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

button[data-action="save"] {
  color: var(--danger);
  border-color: var(--danger);
}

button[data-action="save"]:hover:not(:disabled),
button[data-action="save"]:focus-visible:not(:disabled) {
  color: #fff;
  background: var(--danger);
}

.status-bar,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.status-bar b {
  color: var(--fg);
  font-weight: 700;
}

.file-state {
  max-width: 480px;
  margin-left: auto;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-bar input[type="search"] {
  width: min(360px, 100%);
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  outline: 0;
}

.filter-bar input[type="search"]:focus {
  border-color: var(--fg);
}

.filter-bar label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}

.table-wrap {
  border: 1px solid var(--line);
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #fafafa;
}

.badge {
  display: inline-block;
  min-width: 48px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.badge.default { color: var(--muted); }
.badge.missing { color: var(--info); }
.badge.changed { color: var(--ok); }
.badge.extra { color: var(--danger); }

.field-label {
  display: block;
  font-weight: 700;
}

.field-key {
  display: inline-block;
  max-width: 320px;
  padding: 0;
  margin-top: 2px;
  color: var(--muted);
  background: transparent;
  overflow-wrap: anywhere;
}

.field-help {
  display: block;
  max-width: 560px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-input input,
.field-input select {
  width: 100%;
  min-width: 160px;
  height: 32px;
  padding: 0 8px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  outline: 0;
}

.field-input input:focus,
.field-input select:focus {
  border-color: var(--fg);
}

.default-value {
  display: inline-block;
  max-width: 300px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  overflow-wrap: anywhere;
}

.empty {
  display: grid;
  min-height: 160px;
  place-content: center;
  border: 1px solid var(--line);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  padding: 8px 12px;
  color: #fff;
  background: var(--fg);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 720px) {
  body {
    padding: 16px 10px 48px;
  }

  header h1 {
    font-size: 18px;
  }

  nav,
  .status-bar,
  .filter-bar {
    gap: 7px;
  }

  button {
    height: 30px;
    padding: 0 9px;
  }

  .file-state {
    width: 100%;
    margin-left: 0;
  }
}
