/* ───────── Base ───────── */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: #f5f6f8;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef0f3; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

/* ───────── Topbar ───────── */
.topbar {
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topbar .brand {
  font-weight: 700;
  font-size: 16px;
}
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 6px;
}
.mainnav a:hover { background: #374151; color: #fff; text-decoration: none; }
.mainnav a.active { background: #2563eb; color: #fff; }
.mainnav a.logout { margin-left: auto; color: #f87171; }

/* ───────── Test mode banner ───────── */
.alert-test {
  background: #fef3c7;
  color: #78350f;
  padding: 10px 24px;
  border-bottom: 1px solid #fcd34d;
  font-size: 13px;
}

/* ───────── Container ───────── */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
}
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ───────── Card ───────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ───────── Forms ───────── */
.form label, .filter label {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
}
.filter { display: flex; gap: 12px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filter label { margin: 0; }
input[type=text], input[type=password], input[type=number], textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.filter input { width: auto; }
textarea { resize: vertical; }
fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
}
fieldset legend { font-weight: 500; padding: 0 6px; }
button {
  background: #2563eb;
  color: #fff;
  border: 0;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
button:hover { background: #1d4ed8; }

/* ───────── Tables ───────── */
table.kv {
  width: 100%;
  border-collapse: collapse;
}
table.kv th, table.kv td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
table.kv th { background: #f9fafb; width: 160px; font-weight: 500; color: #4b5563; }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
table.data th, table.data td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  font-size: 13px;
}
table.data th { background: #f9fafb; font-weight: 600; color: #374151; }
table.data tr:hover td { background: #fafbfc; }
table.data td.msg { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── Stats ───────── */
.stats { display: flex; gap: 16px; }
.stat {
  flex: 1;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
}
.stat span { display: block; color: #6b7280; font-size: 12px; margin-bottom: 6px; }
.stat strong { font-size: 24px; color: #1f2937; }

/* ───────── Badges ───────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 500;
}
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ───────── Alerts ───────── */
.success {
  background: #d1fae5;
  color: #065f46;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid #6ee7b7;
  margin-bottom: 16px;
}
.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  margin-bottom: 16px;
}
.muted { color: #6b7280; font-size: 13px; }
small.muted { font-weight: 400; }

/* ───────── Pager ───────── */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }
.pager a {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}

/* ───────── Login ───────── */
.login-bg {
  background: #f5f6f8;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
.login-box h1 { margin: 0 0 4px; text-align: center; }
.login-box .subtitle { text-align: center; color: #6b7280; margin: 0 0 20px; }
.login-box label { display: block; margin-bottom: 14px; font-weight: 500; }
.login-box button { width: 100%; margin-top: 4px; padding: 11px; }

/* ───────── Guide page ───────── */
pre.code, pre.flow {
  background: #1e293b;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  margin: 8px 0 16px;
}
pre.flow {
  background: #f9fafb;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  white-space: pre;
}
.card h3 {
  font-size: 14px;
  margin: 18px 0 8px;
  color: #374151;
}
.card h3:first-of-type { margin-top: 8px; }
.card ul { padding-left: 20px; line-height: 1.8; }
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding: 4px 0; }

/* ───────── Footer ───────── */
.footer {
  text-align: center;
  color: #9ca3af;
  padding: 24px 0;
  font-size: 12px;
}
