/* 控制面板样式。深色为主，信息密度偏高，适合长期盯着看。 */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #949aa8;
  --accent: #4f8cff;
  --ok: #35c07f;
  --bad: #e5484d;
  --warn: #e0a33e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 14px; line-height: 1.7; }
.sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* --- 布局 --- */

.center-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  min-width: 0;
}
.brand a { color: var(--text); }
.brand .home { display: flex; align-items: center; gap: 8px; }
.brand .home:hover { text-decoration: none; color: var(--accent); }
/* 显式写死尺寸，图片没加载完也不会让顶栏抖一下 */
.brand .mark { width: 26px; height: 26px; flex: none; }
.sep { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}

/* --- 登录 / 封禁 --- */

.auth { width: 100%; max-width: 380px; margin: 0; text-align: center; }
.auth .logo { width: 72px; height: 72px; display: block; margin: 6px auto 10px; }
.auth input[type="password"] { margin-top: 14px; }
.auth button { width: 100%; margin-top: 12px; }
.banned .big { font-size: 40px; margin-bottom: 8px; }
.banned code { display: inline-block; }

/* --- 功能卡片 --- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.feature {
  display: block;
  color: var(--text);
  margin: 0;
  transition: border-color .15s, transform .15s;
}
.feature:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.feature .icon { font-size: 26px; margin-bottom: 6px; }
.feature p { color: var(--muted); font-size: 14px; }
.feature .go { color: var(--accent); font-size: 14px; }
.feature.disabled { opacity: .5; pointer-events: none; }

/* --- 表单 --- */

input, select, button, .btn {
  font: inherit;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 9px 12px;
}

input, select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder { color: #5a6070; }

/* --- 玻璃按钮 ---
   静止态是一块半透明玻璃：背后模糊、上缘一道亮边、下缘一道暗边，
   靠这三层做出厚度。悬停时一束光从中心向两端铺开，同时中心有一道
   竖光柱溢出上下边缘再淡出，就是效果图里那种"被点亮"的感觉。

   光带用 clip-path 而不是 overflow:hidden 来裁切——后者会连带把
   要溢出边缘的光柱一起剪掉，那道溢出恰恰是效果图最出彩的地方。 */

button, .btn {
  position: relative;
  isolation: isolate;          /* 伪元素的层级只在按钮内部排 */
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  border-color: rgba(255, 255, 255, .16);
  /* 白色高光叠一层极淡的主色，既是玻璃又还能看出这是主按钮 */
  background:
    linear-gradient(rgba(255, 255, 255, .10), rgba(255, 255, 255, .03)),
    rgba(79, 140, 255, .10);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    inset 0 -1px 0 rgba(0, 0, 0, .28),
    0 2px 8px rgba(0, 0, 0, .28);
  transition: box-shadow .35s ease, border-color .35s ease, color .25s ease;
  /* 光色。danger 会把这两个变量换成红色 */
  --glow: rgba(79, 140, 255, .55);
  --glow-hot: rgba(150, 190, 255, .95);
}

/* 从中心向两端铺开的光带 */
button::before, .btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;                 /* 压在按钮背景之上、文字之下 */
  border-radius: inherit;
  clip-path: inset(0 round 7px);
  background: linear-gradient(90deg,
      transparent 0%, var(--glow) 22%, var(--glow-hot) 50%,
      var(--glow) 78%, transparent 100%);
  opacity: 0;
  transform: scaleX(.08);      /* 起点只是中间一道细缝 */
  transition: transform .5s cubic-bezier(.22, .68, .28, 1), opacity .3s ease;
}

/* 中心那道溢出上下边缘的光柱 */
button::after, .btn::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: -7px;
  bottom: -7px;
  width: 22px;
  margin-left: -11px;
  border-radius: 4px;
  background: var(--glow-hot);
  filter: blur(5px);
  opacity: 0;
}

/* :focus-visible 一并触发——只认 hover 的话，键盘操作的人得不到任何反馈 */
button:hover, .btn:hover,
button:focus-visible, .btn:focus-visible {
  text-decoration: none;
  color: #fff;
  border-color: rgba(255, 255, 255, .34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .34),
    inset 0 -1px 0 rgba(0, 0, 0, .2),
    0 4px 18px -4px var(--glow),
    0 0 34px -10px var(--glow-hot);
}

button:hover::before, .btn:hover::before,
button:focus-visible::before, .btn:focus-visible::before {
  transform: scaleX(1);
  opacity: 1;
}

button:hover::after, .btn:hover::after,
button:focus-visible::after, .btn:focus-visible::after {
  animation: btn-bleed .62s ease-out forwards;
}

/* 光柱先亮起、再随光带铺开而淡出，避免它一直杵在中间 */
@keyframes btn-bleed {
  0%   { opacity: 0;   transform: scaleY(.55); }
  22%  { opacity: .95; transform: scaleY(1); }
  100% { opacity: 0;   transform: scaleY(1.15); }
}

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

/* 次要按钮：同样的玻璃和光效，只是更收敛，不跟主按钮抢视线 */
button.ghost, .ghost.btn {
  color: var(--text);
  padding: 6px 11px;
  font-size: 13px;
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .12),
    0 1px 4px rgba(0, 0, 0, .22);
  --glow: rgba(79, 140, 255, .3);
  --glow-hot: rgba(150, 190, 255, .6);
}
button.ghost::before, .ghost.btn::before { clip-path: inset(0 round 7px); }
button.ghost::after, .ghost.btn::after { top: -5px; bottom: -5px; width: 16px; margin-left: -8px; }

/* 删除是破坏性操作，光色换成红的，和效果图左边那颗一个意思 */
button.danger {
  --glow: rgba(229, 72, 77, .45);
  --glow-hot: rgba(255, 120, 125, .9);
}

/* 用户要求减少动效时，保留颜色与光晕，去掉铺开和闪动 */
@media (prefers-reduced-motion: reduce) {
  button::before, .btn::before {
    transition: opacity .2s ease;
    transform: scaleX(1);
  }
  button::after, .btn::after { display: none; }
  button:active, .btn:active { transform: none; }
}

/* 固定列宽的 grid，而不是 flex 换行：
   字段数量是定死的，用 grid 才能保证目标端口和按钮不被挤到第二行。
   min-width:0 是关键，否则输入框的固有宽度会撑破列宽。 */
.rule-form {
  display: grid;
  grid-template-columns:
    minmax(0, 1.4fr)   /* 规则名称 */
    84px               /* 协议 */
    minmax(0, 1.2fr)   /* 监听地址 */
    92px               /* 监听端口 */
    auto               /* 箭头 */
    minmax(0, 1.4fr)   /* 目标地址 */
    92px               /* 目标端口 */
    auto;              /* 提交按钮 */
  align-items: end;
  gap: 10px;
  margin-top: 16px;
}
.rule-form .field { min-width: 0; }
.rule-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  white-space: nowrap;
}
.rule-form input, .rule-form select { padding: 9px 10px; }
.rule-form .arrow { color: var(--muted); padding-bottom: 10px; }
.rule-form > button, .rule-form > .btn { padding: 9px 14px; }

/* 编辑行里还多一个"取消"，让它跟在按钮后面而不是另起一行 */
.edit-row .rule-form { grid-template-columns:
    minmax(0, 1.4fr) 84px minmax(0, 1.2fr) 92px auto minmax(0, 1.3fr) 92px auto auto; }

/* 窄屏放不下八列，折成两行仍比挤成一列好读 */
@media (max-width: 1000px) {
  .rule-form, .edit-row .rule-form {
    grid-template-columns: minmax(0, 1fr) 84px minmax(0, 1fr) 92px;
  }
  .rule-form .arrow { display: none; }
  .rule-form > button, .rule-form > .btn { grid-column: span 2; }
}

/* --- 提示条 --- */

.alert {
  border-radius: 7px;
  padding: 11px 14px;
  margin: 14px 0;
  font-size: 14px;
  border: 1px solid;
  text-align: left;
}
.alert.ok { background: rgba(53, 192, 127, .1); border-color: rgba(53, 192, 127, .4); }
.alert.error { background: rgba(229, 72, 77, .1); border-color: rgba(229, 72, 77, .45); }

/* --- 表格 --- */

.table-scroll { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
.edit-row:hover, .edit-row { background: var(--panel-2); }

.path code { white-space: nowrap; }
.path .to { color: var(--muted); margin: 0 6px; }
.err-line { color: var(--bad); font-size: 12px; margin-top: 4px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.badge.on { color: var(--ok); border-color: rgba(53, 192, 127, .5); background: rgba(53, 192, 127, .1); }
.badge.off { color: var(--muted); border-color: var(--line); }
.badge.bad { color: var(--bad); border-color: rgba(229, 72, 77, .5); background: rgba(229, 72, 77, .1); }
.live { display: block; font-size: 11px; color: var(--warn); margin-top: 3px; }

.actions { display: flex; gap: 6px; align-items: center; }
.actions form { display: inline; }

.empty { padding: 18px 0; text-align: center; }

@media (max-width: 620px) {
  .rule-form, .edit-row .rule-form { grid-template-columns: minmax(0, 1fr); }
  .rule-form > button, .rule-form > .btn { grid-column: auto; }
  .wrap { padding: 20px 14px 40px; }
}

/* 协议标签：TCP / UDP 一眼分得开 */
.proto {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  border: 1px solid;
}
.proto.tcp { color: #6ea8fe; border-color: rgba(110, 168, 254, .45); background: rgba(110, 168, 254, .1); }
.proto.udp { color: #c08ce0; border-color: rgba(192, 140, 224, .45); background: rgba(192, 140, 224, .1); }

/* 中性提示：会话超时之类的通知，不是错误也不是成功 */
.alert.info { background: rgba(79, 140, 255, .1); border-color: rgba(79, 140, 255, .4); }
