:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --border: rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell { max-width: 1200px; margin: 0 auto; padding: 20px 20px 48px; }

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.brand { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); font-size: 0.95rem; }
.spacer { flex: 1; }

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(0, 0, 0, 0.08); }
.btn-round {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
.btn-round:hover { background: rgba(0, 0, 0, 0.08); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.icon-cog::before { content: "⚙"; font-size: 1.1rem; }

.sync-diag-panel {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.sync-diag-panel summary { cursor: pointer; font-weight: 600; }
.sync-diag-body { padding-top: 10px; }
.sync-diag-help { font-size: 0.85rem; color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.sync-diag-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.sync-diag-token { flex: 1; min-width: 200px; max-width: 420px; }
.sync-diag-out {
  display: block;
  max-height: 480px;
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.input-round, .select-round {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  min-width: 0;
}
.input-round { flex: 1 1 200px; max-width: 320px; }
.select-round { min-width: 180px; }

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tr:hover td { background: rgba(0, 0, 0, 0.02); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.06);
}
.badge-ok { background: rgba(52, 199, 89, 0.2); color: #1a7f37; }
.badge-fail { background: rgba(255, 59, 48, 0.15); color: #c41a0e; }
.badge-block { background: rgba(255, 149, 0, 0.2); color: #a35a00; }

.expand-row td { background: #fafafa; border-bottom: none; }
.json-blocks { display: flex; flex-direction: column; gap: 12px; padding: 8px 0 16px; }
.json-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.json-block summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 500;
  list-style: none;
}
.json-block summary::-webkit-details-marker { display: none; }
.json-block pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 220px;
  overflow: auto;
  font-size: 0.75rem;
  background: #fbfbfc;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.copy-row { padding: 8px 14px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.view { display: none; }
.view.active { display: block; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 24px 28px;
  width: min(440px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.modal-card h2 { margin: 0 0 16px; font-size: 1.25rem; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.toggle { flex-direction: row !important; align-items: center; gap: 10px !important; color: var(--text) !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 36px;
  text-align: center;
}
.login-logo { margin-bottom: 12px; }
.login-logo img { display: block; margin: 0 auto; }
.login-title { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin: 8px 0 24px; }
.login-form { text-align: left; }
.login-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.login-input { width: 100%; }
.login-err { color: #c41e1e; font-size: 0.85rem; margin: 8px 0 0; }
.login-submit { width: 100%; margin-top: 16px; }

.hook-body-pre {
  max-height: 7rem;
  overflow: auto;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
}
