/* ── envViewer · white light mode ─────────────────────────────────────── */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.hidden { display: none !important; }

/* ── top bar ──────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.logo {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--accent);
  display: inline-block;
  flex: none;
}
.brand-name { letter-spacing: -.01em; }

.live {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: color .2s, border-color .2s;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  margin-right: 6px;
  vertical-align: 1px;
}
.live.on { color: var(--ok); border-color: #bbe7c8; }
.live.off { color: var(--danger); border-color: #f3c6c6; }

.stats { display: flex; gap: 18px; margin-left: auto; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.sep { padding-left: 18px; border-left: 1px solid var(--border); }

.top-actions { display: flex; align-items: center; }

/* ── buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #fafbfc; border-color: #98a2b3; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }

/* ── login overlay ────────────────────────────────────────────────────── */

.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.login-field { display: flex; gap: 8px; }
.login-field input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.login-error { color: var(--danger); font-size: 13px; margin: 12px 0 0; }
.login.shake .login-card { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ── layout ───────────────────────────────────────────────────────────── */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── search card ──────────────────────────────────────────────────────── */

.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.search-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon { color: var(--muted); display: inline-flex; align-items: center; }
.search-icon svg { width: 16px; height: 16px; }

#q {
  flex: 1;
  border: none;
  outline: none;
  padding: 11px 0;
  font-size: 15px;
  background: transparent;
}
#q::placeholder { color: #98a2b3; }

.clear-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
}
.clear-btn:hover { color: var(--text); background: var(--bg); }

.search-meta { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  padding: 0 2px;
}

.pills {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.pill:hover { color: var(--text); }
.pill.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.opt-group { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check select {
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.check select:focus { border-color: var(--accent); }
.check-label { text-transform: lowercase; }

.hint { font-size: 12px; color: var(--muted); width: 100%; }

/* ── table ────────────────────────────────────────────────────────────── */

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 57px;
  z-index: 10;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: #fbfcfd;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  white-space: nowrap;
}

.col-id { width: 60px; color: #b0b8c4 !important; }
.col-key { width: 40%; }
.col-val { }
.col-actions { width: 96px; }

tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid #f0f1f4;
  vertical-align: top;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8faff; }

td.id-cell { color: #b0b8c4; font-size: 11px; }

.key-cell { font-weight: 600; color: var(--accent-hover); }
.val-cell {
  color: #344054;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
tbody tr:hover .cell-actions { opacity: 1; }

.copy-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: inherit;
  transition: all .15s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.copy-btn.done { color: var(--ok); border-color: #bbe7c8; background: #f0fdf4; }

.score-badge {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  font-family: inherit;
  vertical-align: 1px;
}

/* skeletons */
tbody tr.skel td { height: 34px; }
.skel .bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #f0f1f4 25%, #fafbfc 50%, #f0f1f4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  width: 60%;
}
.skel .bar.w70 { width: 70%; }
.skel .bar.w40 { width: 40%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── empty states ─────────────────────────────────────────────────────── */

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; font-size: 14px; color: var(--text); font-weight: 600; }
.empty .empty-sub { font-size: 13px; font-weight: 400; color: var(--muted); }

/* ── pager ────────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}
.page-info { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.page-actions { display: flex; align-items: center; gap: 10px; }
.page-num { font-size: 13px; color: var(--muted); }
.page-num b { color: var(--text); }

/* ── toast ────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #101828;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── responsive ───────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .stats .stat.sep { display: none; }
  .opt-group { margin-left: 0; width: 100%; }
  .search-meta { display: none; }
  .col-id { display: none; }
}
