:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e3e6eb;
  --text: #16181d;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-2: #1f57c9;
  --ok-bg: #e7f6ec;
  --ok-fg: #17703a;
  --err-bg: #fdecec;
  --err-fg: #a52424;
  --warn-bg: #fff6e5;
  --warn-fg: #8a5a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--primary); color: #fff;
  border-radius: 9px; font-size: 12px; font-weight: 700;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: #eef3ff; color: var(--primary-2); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user { color: var(--muted); font-size: 13px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }
.container-narrow { max-width: 430px; display: grid; place-items: center; padding-top: 8vh; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.notice { border-left: 3px solid var(--primary); }
.login-card { width: 100%; padding: 26px; }
.login-card h1 { margin-bottom: 6px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head .actions { display: flex; gap: 8px; align-items: center; }
.back { font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 4px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .grid-2, .grid-4, .grid-6 { grid-template-columns: 1fr; }
  .nav { display: none; }
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.stat-sub { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 550; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.inline { display: inline; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.input-sm { width: 90px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; color: #374151; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text);
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #c9d9ff; border-color: var(--primary);
}
textarea { resize: vertical; }
.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 550; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid #f0f1f4; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .right { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }

.kv { display: grid; grid-template-columns: 210px 1fr; gap: 9px 14px; margin: 0 0 14px; font-size: 14px; }
.json-block {
  margin: 0; max-height: 480px; overflow: auto; white-space: pre-wrap;
  font-size: 12px; line-height: 1.45; background: var(--surface-2); padding: 12px; border-radius: 8px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef0f3; color: #4b5563;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-error { background: var(--err-bg); color: var(--err-fg); }
.badge-muted { background: #eef0f3; color: #4b5563; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash-error { background: var(--err-bg); color: var(--err-fg); }
.flash-info { background: #eef3ff; color: #1e40af; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--err-fg); font-size: 12px; max-width: 380px; word-break: break-word; }
.mt { margin-top: 16px; }
.right { text-align: right; }
.filters { margin-bottom: 16px; }
.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-row .grow { flex: 1; min-width: 220px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 14px; }
.footer {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px 24px;
  color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 12px;
}
