/* ============================================================
   服务入口 · home.lxhuimeng.top
   版式：左侧固定导航栏 + 右侧服务列表行；主题：冷灰蓝 + 信号蓝强调色
   ============================================================ */

:root {
  --bg: #eceff4;
  --bg-grid: rgba(20, 32, 58, 0.035);
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --surface-3: #eaeef6;
  --border: #dbe1ec;
  --border-strong: #c6cfe0;
  --text: #0d1320;
  --text-soft: #3a4557;
  --muted: #66748a;
  --accent: #2f5cff;
  --accent-soft: rgba(47, 92, 255, 0.1);
  --accent-2: #7c4dff;
  --up: #0f9d6a;
  --down: #d2553c;
  --shadow-sm: 0 1px 2px rgba(13, 19, 32, 0.06);
  --shadow: 0 14px 34px -24px rgba(13, 19, 32, 0.5);
  --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  --bg: #06090f;
  --bg-grid: rgba(150, 180, 255, 0.045);
  --surface: #0e141f;
  --surface-2: #151d2b;
  --surface-3: #1b2536;
  --border: #1f2939;
  --border-strong: #2d3a4f;
  --text: #e7edf7;
  --text-soft: #aebbd0;
  --muted: #7c8a9f;
  --accent: #5b83ff;
  --accent-soft: rgba(91, 131, 255, 0.14);
  --up: #2ecb92;
  --down: #e8795f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 20px 44px -30px rgba(0, 0, 0, 0.95);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sprite {
  display: none;
}

.i {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hide-light {
  display: none;
}

html[data-theme="dark"] .hide-light {
  display: block;
}

html[data-theme="dark"] .hide-dark {
  display: none;
}

.only-narrow {
  display: none;
}

/* ---------------- 骨架 ---------------- */
.app {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------------- 左栏 ---------------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px 18px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-radius: 11px;
  box-shadow: 0 10px 22px -14px var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.brand-text strong {
  font-size: 14.5px;
}

.brand-text small {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.rail-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rail-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rail-search .i {
  font-size: 15px;
  color: var(--muted);
}

.rail-search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13.5px;
  color: inherit;
  background: none;
  border: 0;
  outline: none;
}

.rail-search input::placeholder {
  color: var(--muted);
}

.rail-search .clear {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.rail-search .clear:hover {
  color: var(--text);
  background: var(--surface-3);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
  background: none;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 3px;
  height: 0;
  background: var(--accent);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: height 0.16s;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-item[aria-pressed="true"]::before {
  height: 18px;
}

.nav-item .count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.rail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.rail-stats b {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.rail-stats .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
}

.rail-stats .dot.up {
  background: var(--up);
}

.rail-stats .dot.down {
  background: var(--down);
}

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

.rail-actions .btn {
  flex: 1;
  justify-content: center;
}

.rail-clock {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn-accent {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.btn-accent:hover {
  background: color-mix(in srgb, var(--accent) 84%, #fff);
  border-color: transparent;
}

.btn-danger {
  color: var(--down);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--down) 10%, transparent);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 15px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------------- 主区 ---------------- */
.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 26px 40px;
  min-width: 0;
}

.main-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.main-title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.015em;
}

.main-title p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.stamp {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.managebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 11px 13px;
  background: var(--accent-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius);
}

/* ---------------- 分组与行 ---------------- */
.directory {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.group-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.group-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.group-head .count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(150px, 1.05fr) minmax(160px, 1.35fr) auto;
  align-items: center;
  gap: 8px 14px;
  padding: 11px 14px 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.row::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--acc);
  opacity: 0;
  transition: opacity 0.15s;
}

.row:hover {
  transform: translateX(2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.row:hover::after {
  opacity: 1;
}

.row:focus-within {
  border-color: var(--accent);
}

.row-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius);
}

.row-open span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mark {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 46px;
  height: 38px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(150deg, var(--acc), color-mix(in srgb, var(--acc) 45%, #0b1220));
  border-radius: 9px;
  pointer-events: none;
}

.row-id {
  position: relative;
  z-index: 2;
  min-width: 0;
  pointer-events: none;
}

.row-id h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-id .host {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-desc {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft);
  pointer-events: none;
}

.row-meta {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 8px;
  pointer-events: none;
}

.kind,
.tag {
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: nowrap;
}

.tag {
  font-family: var(--mono);
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--up);
  white-space: nowrap;
}

.status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}

.status.is-down {
  color: var(--down);
}

.note {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

.row-actions .manage-only {
  display: none;
}

body.is-managing .row-actions .manage-only {
  display: grid;
}

body.is-managing .row-open {
  pointer-events: none;
}

.row-actions button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.row-actions button:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.row-actions .copy.is-copied {
  color: var(--up);
}

.row-actions .danger:hover {
  color: var(--down);
  background: color-mix(in srgb, var(--down) 10%, transparent);
}

/* ---------------- 空态 / 页脚 ---------------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.empty p {
  margin: 0 0 15px;
  font-size: 13px;
  color: var(--muted);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 18px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------- 对话框 ---------------- */
.dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop {
  background: rgba(6, 9, 15, 0.6);
  backdrop-filter: blur(3px);
}

.form {
  display: flex;
  flex-direction: column;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 0;
  font-size: 16px;
}

.dialog-head p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 14px;
  padding: 17px 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span:first-child {
  font-size: 12.5px;
  color: var(--text-soft);
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  font: inherit;
  font-size: 14px;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field.has-error input {
  border-color: var(--down);
}

.err {
  font-size: 12px;
  color: var(--down);
}

.color {
  display: flex;
  align-items: center;
  gap: 9px;
}

.color input[type="color"] {
  width: 46px;
  padding: 3px;
  cursor: pointer;
}

.color code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 20px 17px;
  border-top: 1px solid var(--border);
}

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  font-size: 13.5px;
  color: #fff;
  background: #0d1320;
  border-radius: 10px;
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 80;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  margin: 40px auto;
  max-width: 520px;
  padding: 16px 18px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.scrim {
  display: none;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .row {
    grid-template-columns: 46px minmax(140px, 1fr) minmax(0, 1.1fr) auto;
  }

  .row-desc {
    display: none;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .only-narrow {
    display: grid;
  }

  .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 300px);
    height: 100vh;
    z-index: 60;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
  }

  body.rail-open .rail {
    transform: none;
  }

  body.rail-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(6, 9, 15, 0.45);
  }

  .main {
    padding: 16px 14px 32px;
  }

  .row {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 6px 12px;
  }

  .row-meta {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  .row:hover {
    transform: none;
  }
}
