/* ============================================================
   Keyvault Console — 一个 API key 中转金库的仪表台
   深色两级表面 + teal 信号色（只用于交互/品牌）+ 指示灯式状态
   ============================================================ */

:root {
  --ink:      #0b0d12;   /* 底 */
  --panel:    #14171f;   /* 卡片/顶栏 */
  --panel-2:  #1b1f29;   /* 输入框/内嵌块 */
  --panel-3:  #212633;   /* 悬浮/高亮 */
  --line:     #262b36;   /* 分隔线 */
  --line-2:   #2f3644;

  --text:     #e7eaf0;
  --muted:    #8b93a3;
  --faint:    #626b7b;

  --signal:   #34e0cf;   /* 信号色：品牌 / 主按钮 / 焦点 / 链接 —— 绝不用于状态 */
  --signal-d: #17b7a7;
  --signal-ink:#042420;

  --ok:   #4ade80;
  --warn: #f5b843;
  --bad:  #fb7185;
  --slate:#98a2b3;

  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  --font-disp: "Segoe UI Variable Display", "Segoe UI Semibold", "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", ui-monospace, Consolas, "Microsoft YaHei", monospace;

  --r:  12px;
  --r-sm: 8px;
  --shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 78% -8%, rgba(52,224,207,.06), transparent 60%),
    radial-gradient(900px 500px at 8% 4%, rgba(78,110,255,.05), transparent 55%),
    var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--signal); text-decoration: none; }
a:hover { color: #6bf0e2; text-decoration: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- 顶栏 / 品牌 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent), var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.1);
}
/* 品牌：🔑 Key 库 + 尾随「运行中」呼吸灯（纯 CSS，不依赖模板结构） */
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-disp);
  font-weight: 700; font-size: 16px; letter-spacing: .2px;
  padding: 4px 8px 4px 4px;
}
.brand::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--signal); box-shadow: 0 0 9px var(--signal);
  animation: livepulse 2.4s ease-in-out infinite;
}
@keyframes livepulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.82)} }

nav { display: flex; align-items: center; gap: 4px; }
nav > a {
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  padding: 7px 11px; border-radius: 8px; line-height: 1;
  transition: color .15s, background .15s;
}
nav > a:hover { color: var(--text); background: var(--panel-2); }
nav .who {
  color: var(--faint); font-size: 12.5px; margin-left: 8px;
  padding-left: 12px; border-left: 1px solid var(--line);
}

.inline { display: inline; margin: 0; }
button.link { background: none; border: none; color: var(--muted); cursor: pointer; padding: 7px 10px; font-size: 13.5px; }
button.link:hover { color: var(--text); background: transparent; }

/* ---------- 布局 / 卡片 ---------- */
main { max-width: 1120px; margin: 26px auto 60px; padding: 0 22px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 400px; margin: 68px auto; }

h1 {
  margin: 0 0 4px; font-family: var(--font-disp);
  font-size: 22px; font-weight: 650; letter-spacing: -.2px;
}
h1 .dim { font-weight: 400; letter-spacing: 0; }
h2 { font-size: 15px; font-weight: 650; margin: 26px 0 10px; color: var(--text); }

.hint, .dim { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); }

/* ---------- 表单 ---------- */
label { display: block; margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, textarea, select {
  width: 100%; padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--signal-d);
  background: #10141b;
  box-shadow: 0 0 0 3px rgba(52,224,207,.16);
}
textarea { resize: vertical; font-family: var(--font-mono); line-height: 1.55; }
select { cursor: pointer; }

.check { display: flex; align-items: center; gap: 9px; margin: 10px 0; }
.check input { width: auto; }

/* ---------- 按钮 ---------- */
button, .btn, a.sm {
  font-family: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); cursor: pointer; text-decoration: none;
  display: inline-block; line-height: 1.3;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
button:hover, .btn:hover, a.sm:hover { background: var(--panel-3); border-color: var(--line-2); }
button:active, .btn:active { transform: translateY(1px); }

button.primary, .btn.primary {
  background: var(--signal); border-color: transparent; color: var(--signal-ink);
  font-weight: 650; box-shadow: 0 6px 18px -8px rgba(52,224,207,.6);
}
button.primary:hover, .btn.primary:hover { background: #47ecdb; color: var(--signal-ink); }

button.sm, a.sm { padding: 5px 11px; font-size: 12px; font-weight: 500; }
button.danger, .sm.danger, .btn.danger { color: var(--bad); border-color: rgba(251,113,133,.32); background: rgba(251,113,133,.06); }
button.danger:hover { background: rgba(251,113,133,.14); }

.sm-in { width: 120px; display: inline-block; margin: 0; padding: 6px 9px; }

.rowacts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rowacts form { margin: 0; }

.pf-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.pf-choices .check {
  margin: 0; padding: 9px 14px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--panel-2);
  transition: border-color .15s, background .15s;
}
.pf-choices .check:hover { border-color: var(--signal-d); background: #10141b; }

/* ---------- Flash ---------- */
.flash {
  padding: 11px 15px; border-radius: var(--r-sm); margin-bottom: 14px;
  font-size: 13.5px; border: 1px solid; display: flex; gap: 9px; align-items: center;
}
.flash::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }
.flash.ok    { background: rgba(74,222,128,.08);  border-color: rgba(74,222,128,.3);  color: #86efac; }
.flash.error { background: rgba(251,113,133,.08); border-color: rgba(251,113,133,.3); color: #fca5a5; }
.flash.warn  { background: rgba(245,184,67,.08);  border-color: rgba(245,184,67,.3);  color: #fde68a; }

/* ---------- 表格（本应用的主体） ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 14px; }
table.grid th, table.grid td {
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.grid thead th {
  position: sticky; top: 58px; z-index: 5;
  color: var(--muted); font-weight: 600; font-size: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: rgba(255,255,255,.022); }
table.grid td.mono { color: #cdd3dd; }
td.err { color: #fca5a5; max-width: 260px; word-break: break-all; font-size: 12.5px; }
td.reveal { cursor: pointer; }
td.reveal:hover { color: var(--signal); }
th:last-child, td:last-child { text-align: left; }

/* ---------- 状态：指示灯 ---------- */
.st { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.st::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 8px currentColor; flex: none;
}
.st-pending   { color: var(--slate); }
.st-uploading { color: var(--warn); }
.st-uploaded  { color: var(--ok); }
.st-failed    { color: var(--bad); }
.st-uploading::before { animation: blink 1.15s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---------- 概览统计：仪表簇 ---------- */
.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 130px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; text-align: left; position: relative; overflow: hidden;
  transition: border-color .15s, transform .12s;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-2); }
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--slate); opacity: .8;
}
.stat.pending::after   { background: var(--slate); }
.stat.uploading::after { background: var(--warn); }
.stat.uploaded::after  { background: var(--ok); }
.stat.failed::after    { background: var(--bad); }
.stat .num {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -.5px;
}
.stat .lbl, .stat > div:not(.num) { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat.pending .num   { color: #cbd5e1; }
.stat.uploading .num { color: var(--warn); }
.stat.uploaded .num  { color: var(--ok); }
.stat.failed .num    { color: var(--bad); }
.mt { margin-top: 18px; }

/* ---------- 筛选栏 / 分页 ---------- */
.filters { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; font-size: 13.5px; }
.filters b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
.filters a { padding: 5px 11px; border-radius: 7px; border: 1px solid var(--line-2); color: var(--muted); }
.filters a:hover { background: var(--panel-2); color: var(--text); }
.filters a.on { background: var(--signal); border-color: transparent; color: var(--signal-ink); font-weight: 600; }

.filterbar {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 16px; padding: 16px 18px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r);
}
.filterbar label { display: flex; flex-direction: column; gap: 5px; margin: 0; font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.filterbar select, .filterbar input { width: auto; min-width: 140px; margin: 0; padding: 8px 10px; }
.filterbar .primary { margin-left: auto; }
.pager { justify-content: center; margin-top: 16px; gap: 8px; }
.pager .dim { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- fieldset（表单分组） ---------- */
fieldset { border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 18px; padding: 10px 18px 18px; }
legend { color: var(--signal); font-size: 12px; font-weight: 600; padding: 0 8px; text-transform: uppercase; letter-spacing: .05em; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row input, .row select { width: auto; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.actions form.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.actions .sm-in { margin: 0; }
.actions .sm { white-space: nowrap; }
.settings label { font-weight: 500; }

/* ---------- 可访问性 ---------- */
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .brand::after, .st-uploading::before { animation: none !important; }
  * { transition: none !important; }
}

@media (max-width: 720px) {
  main { padding: 0 14px; margin-top: 16px; }
  .card { padding: 18px 16px; }
  .topbar { padding: 12px 14px; }
  nav > a { padding: 6px 8px; }
  table.grid thead th { top: 52px; }
}
