/* ==========================================================
   base.css — 공통 (변수 · 리셋 · 상단바 · 폼/버튼 공통)
   단위는 rem / em / % 위주. (헤어라인 테두리만 px)
   ========================================================== */

:root {
  /* 색 */
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --surface-2:   #fafbfc;
  --line:        #e4e7ec;
  --line-strong: #d0d5dd;
  --text:        #1a2233;
  --muted:       #667085;
  --faint:       #98a2b3;

  --accent:      #2f6feb;
  --accent-dark: #2559c4;
  --accent-soft: #eaf1fe;

  --danger:      #d64545;
  --danger-dark: #b93636;
  --danger-soft: #fdecec;
  --ok:          #15883e;
  --ok-soft:     #e7f6ec;

  /* 모양 */
  --radius:    0.625rem;
  --radius-sm: 0.375rem;
  --shadow:    0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 0.75rem 2rem rgba(16, 24, 40, .16);

  /* 크기 */
  --topbar-h: 3.5rem;
  --page-max: 100%;
}

* { box-sizing: border-box; }

html { font-size: 100%; }           /* 1rem = 브라우저 기본(보통 16px) */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", -apple-system, BlinkMacSystemFont,
               "Segoe UI", system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* hidden 속성은 항상 우선. (.btn·.chip 처럼 display 를 지정한 요소도 숨겨지도록)
   이게 없으면 개발자 CSS의 display 가 브라우저 기본 [hidden] 을 이겨서 안 숨겨짐 */
[hidden] { display: none !important; }


/* ── 상단바 ───────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--muted);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand b { color: var(--text); font-weight: 700; }

.brand-mark {
  width: 1.125em;
  height: 1.125em;
  border-radius: 0.3em;
  background: linear-gradient(135deg, var(--accent), #7aa2f7);
}

.nav { display: flex; gap: 0.25rem; }

.nav a {
  padding: 0.45em 0.9em;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on    { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

/* 크롤 도우미(로컬 에이전트) 상태 배지 */
.agent-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.7em;
  border-radius: 999em;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
  user-select: none;
}
.agent-badge::before {
  content: "";
  width: 0.5em; height: 0.5em; border-radius: 50%;
  background: currentColor;
}
.agent-badge.checking { color: var(--faint);  background: var(--surface-2); }
.agent-badge.on       { color: var(--ok);     background: var(--ok-soft);     border-color: transparent; }
.agent-badge.off      { color: var(--danger); background: var(--danger-soft); border-color: transparent; }


/* ── 페이지 ───────────────────────────────── */
.page {
  max-width: var(--page-max);
  padding: 1.25rem 1.5rem 2.5rem;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.page-sub   { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.8125rem; }


/* ── 카드 ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}


/* ── 폼 요소 공통 ─────────────────────────── */
input[type="text"], input[type="search"], select {
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.45em 0.65em;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="search"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875em var(--accent-soft);
}
select { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.5em 0.9em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

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

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); border-color: var(--danger-dark); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }


/* ── 작은 조각 ────────────────────────────── */
.chip {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 999em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }
.chip-ok     { background: var(--ok-soft);     border-color: transparent; color: var(--ok); }

.muted { color: var(--muted); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--faint); }
