:root {
  --ink: #0c1a1f;
  --bg: #eef3f1;
  --panel: #ffffff;
  --line: #d5e0dc;
  --text: #142428;
  --muted: #5f7370;
  --accent: #0d8f7a;
  --accent-2: #0a6e5e;
  --accent-soft: #d8f3ec;
  --ok: #1f9d63;
  --warn: #c9841a;
  --bad: #c23b45;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(12, 26, 31, 0.06);
  --font: "DM Sans", "PingFang SC", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background:
    radial-gradient(900px 420px at 100% -10%, #c9ebe3 0%, transparent 55%),
    radial-gradient(700px 380px at -5% 20%, #d7e4f2 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem;
}
select {
  height: 42px; line-height: 1.2; padding-top: 0; padding-bottom: 0;
  max-width: 100%;
}
select.field-sm, .field-sm {
  height: 40px; padding-left: 0.75rem; padding-right: 0.75rem;
}
button {
  cursor: pointer; background: var(--accent); border-color: transparent;
  color: #fff; font-weight: 600; transition: background .15s, transform .1s;
}
button:hover { background: var(--accent-2); }
button:active { transform: translateY(1px); }
button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
button.secondary:hover { background: #f4f8f6; }
button.danger { background: var(--bad); }
button.ghost { background: transparent; color: var(--muted); border: 0; padding: 0.35rem 0.5rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
label { display: grid; gap: 0.35rem; font-size: 0.86rem; color: var(--muted); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.9rem; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.shell { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.top {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem;
  padding: 0.85rem 1rem; background: rgba(255,255,255,0.72);
  border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.brand {
  display: flex; align-items: baseline; gap: 0.45rem; min-width: 120px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(145deg, #14b89a, #0a6e5e);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav button {
  background: transparent; color: var(--muted); border: 0; font-weight: 500;
  padding: 0.45rem 0.75rem; border-radius: 999px;
}
.nav button.active { color: var(--accent-2); background: var(--accent-soft); }
.user-menu { position: relative; margin-left: auto; }
.user-btn {
  display: flex; align-items: center; gap: 0.5rem;
  background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.35rem 0.7rem 0.35rem 0.4rem; font-weight: 500;
}
.avatar {
  width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-2); font-size: 0.75rem; font-weight: 700;
}
.user-drop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 160px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 0.4rem; z-index: 20; display: none;
}
.user-drop.open { display: block; }
.user-drop button {
  width: 100%; text-align: left; background: transparent; color: var(--text);
  border: 0; font-weight: 500; padding: 0.55rem 0.7rem; border-radius: 8px;
}
.user-drop button:hover { background: #f3f7f5; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 0.85rem; font-size: 1.08rem; letter-spacing: -0.02em; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.9rem; flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.muted { color: var(--muted); font-size: 0.85rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td {
  text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle;
}
.table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: none; }
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.18rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: #eef2f1; color: var(--muted);
}
.badge.ok { background: #e5f7ee; color: var(--ok); }
.badge.fail { background: #fdebec; color: var(--bad); }
.badge.draft { background: #fff4e5; color: var(--warn); }
.badge.paused { background: #eef1f5; color: #526070; }
.badge.deprecated { background: #fff4e5; color: var(--warn); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
}
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.75rem; letter-spacing: -0.03em; }
.form { display: grid; gap: 0.85rem; }
.err { color: var(--bad); font-size: 0.9rem; }
.okmsg { color: var(--ok); font-size: 0.9rem; }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.45rem 1rem; }
.checkboxes label { display: flex; align-items: center; gap: 0.35rem; color: var(--text); font-weight: 400; }
textarea { min-height: 88px; width: 100%; resize: vertical; }
.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.section {
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: #fbfdfc;
}
.section + .section { margin-top: 0.9rem; }
.section-title {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.95rem; font-weight: 650; color: var(--ink); margin-bottom: 0.75rem;
}
.help-btn {
  width: 20px; height: 20px; border-radius: 999px; padding: 0;
  display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 700;
  background: #e7f0ed; color: var(--accent-2); border: 0;
}
.help-pop {
  display: none; margin: 0.35rem 0 0.75rem; padding: 0.7rem 0.85rem;
  background: #f2f8f6; border-radius: 10px; color: var(--muted); font-size: 0.82rem; line-height: 1.5;
}
.help-pop.open { display: block; }

.pager { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; margin-top: 0.85rem; }
.pager .muted { margin-right: auto; }

.chart-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.chart-box { min-height: 220px; }
.chart-svg { width: 100%; height: 220px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.3rem; }

.tag-input {
  display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.45rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-height: 44px; align-items: center;
}
.tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--accent-soft); color: var(--accent-2);
  border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.8rem; font-weight: 600;
}
.tag button { background: transparent; border: 0; color: var(--accent-2); padding: 0; font-size: 0.9rem; }
.tag-input input { border: 0; outline: none; flex: 1; min-width: 120px; padding: 0.3rem; }

.name-rule-panel {
  border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden;
}
.name-rule-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--line); background: #f7faf9; flex-wrap: wrap;
}
.name-rule-tabs button {
  flex: 1; min-width: 88px; border: 0; border-radius: 0; background: transparent;
  color: var(--muted); font-weight: 500; padding: 0.7rem 0.5rem;
}
.name-rule-tabs button.active {
  color: var(--accent-2); background: #fff;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.name-rule-body { padding: 0.9rem; display: grid; gap: 0.75rem; }
.name-rule-add {
  display: grid; grid-template-columns: 140px 1fr auto; gap: 0.5rem; align-items: center;
}
@media (max-width: 700px) {
  .name-rule-add { grid-template-columns: 1fr; }
}
.name-rule-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; min-height: 28px; }
.name-rule-chips .chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--accent-soft); color: var(--accent-2);
  border-radius: 999px; padding: 0.28rem 0.6rem; font-size: 0.8rem; font-weight: 600;
}
.name-rule-chips .chip button {
  background: transparent; border: 0; color: var(--accent-2); padding: 0; line-height: 1;
}
.name-rule-chips .empty { color: var(--muted); font-size: 0.82rem; }

.empty-state {
  display: grid; place-items: center; text-align: center;
  padding: 2.5rem 1.25rem 2rem; gap: 0.75rem;
}
.empty-state svg { width: min(220px, 70vw); height: auto; }
.empty-state h3 { margin: 0.4rem 0 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.empty-state p { margin: 0; color: var(--muted); max-width: 360px; line-height: 1.5; }

.combo-field { display: grid; gap: 0.45rem; }
.combo-field .custom-url { display: none; }
.combo-field.custom .custom-url { display: block; }

.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.tabs button {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 999px; font-weight: 500;
}
.tabs button.active { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }

.flash {
  margin-bottom: 0.85rem; padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem;
}
.flash.ok { background: #e5f7ee; color: var(--ok); }
.flash.err { background: #fdebec; color: var(--bad); }
