/* sa-token 管理后台：扁平、圆角、圆形图标 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e8ecf3;
  --text: #1f2937;
  --muted: #8a94a6;
  --blue: #4f7cff;
  --green: #1fb37a;
  --orange: #f59e0b;
  --red: #ef5f67;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --gray: #94a3b8;
  --radius: 18px;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 13px; }
code { background: #eef2ff; color: #4338ca; padding: 1px 8px; border-radius: 999px; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 14px; margin: 0; }
small { color: var(--muted); font-size: 12px; }
.block { display: block; }
.muted { color: var(--muted); }
.bad-text { color: var(--red); }
.right { text-align: right; }
.break { word-break: break-all; }

/* 图标 */
.i { width: 18px; height: 18px; flex: none; }
.dot {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: #eef1f7; color: #5b6475;
}
.dot.sm { width: 26px; height: 26px; }
.dot.sm .i { width: 14px; height: 14px; }
.dot.lg { width: 48px; height: 48px; }
.dot.lg .i { width: 22px; height: 22px; }
.blue { --c: var(--blue); }
.green { --c: var(--green); }
.orange { --c: var(--orange); }
.red { --c: var(--red); }
.purple { --c: var(--purple); }
.teal { --c: var(--teal); }
.gray { --c: var(--gray); }
.dot[class*=" "]:is(.blue, .green, .orange, .red, .purple, .teal, .gray) {
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white);
}

/* 侧栏 */
.side {
  width: 220px; flex: none; background: var(--card); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 6px; }
.brand small { display: block; font-weight: 400; }
.logo {
  width: 38px; height: 38px; border-radius: 50%; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px;
}
.logo.big { width: 64px; height: 64px; font-size: 22px; margin: 0 auto; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  display: flex; align-items: center; gap: 12px; padding: 7px 14px 7px 7px;
  border-radius: 999px; color: #4b5563; font-weight: 500;
}
.side nav a:hover { background: #f3f5fa; }
.side nav a.on { background: #eef2ff; color: var(--blue); }
.side nav a.on .dot { background: var(--blue); color: #fff; }
.logout { margin-top: auto; }

main { flex: 1; min-width: 0; padding: 28px 34px 60px; display: flex; flex-direction: column; gap: 18px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.head p { margin: 4px 0 0; }
.with-back { display: flex; align-items: center; gap: 14px; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.flush { padding: 0; }
.pad { padding: 18px 20px 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.grid2.wide-left { grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .grid2.wide-left { grid-template-columns: 1fr; } }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px; transition: border-color .15s;
}
.stat:hover { border-color: #cfd8ea; }
.stat b { font-size: 24px; display: block; line-height: 1.2; }
.stat em { font-style: normal; font-size: 15px; color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* 按钮：椭圆 pill 与圆形 icon button */
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; list-style: none;
}
.pill .i { width: 16px; height: 16px; }
.pill:hover { background: #f5f7fb; }
.pill.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.pill.primary:hover { background: #3f6cf0; }
.pill.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, white); }
.pill.danger:hover { background: #fff1f2; }
.pill.ghost { border-color: transparent; color: var(--muted); }
.pill.wide { width: 100%; justify-content: center; height: 42px; }
.ib {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
  display: inline-grid; place-items: center; list-style: none;
  color: var(--c, #5b6475); background: color-mix(in srgb, var(--c, #94a3b8) 12%, white);
  transition: transform .1s, background .15s;
}
.ib .i { width: 16px; height: 16px; }
.ib:hover { background: var(--c, #64748b); color: #fff; }
.ib:active { transform: scale(.92); }
.ib:disabled { opacity: .35; cursor: not-allowed; background: #f1f5f9; color: var(--gray); }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }

/* 表格 */
.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap;
}
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.card.flush > .list thead th:first-child { border-top-left-radius: var(--radius); }
.card.flush > .list thead th:last-child { border-top-right-radius: var(--radius); }
.list tbody tr:last-child td { border-bottom: none; }
.list tbody tr:hover td { background: #fafbff; }
.list.compact td, .list.compact th { padding: 8px 14px; }
.list .empty, .empty { text-align: center; color: var(--muted); padding: 34px; }
.scroll { overflow-x: auto; }
.ops { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.ops form { margin: 0; }

.who { display: flex; align-items: center; gap: 12px; }
.who b { display: block; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700;
  display: grid; place-items: center; flex: none;
}
.avatar.key { background: color-mix(in srgb, var(--purple) 14%, white); color: var(--purple); }

/* 状态胶囊 */
.state {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.led { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.state.active { color: #0f8f5f; background: #e7f8f0; }
.state.frozen { color: #b45309; background: #fef3e2; }
.state.expired { color: #64748b; background: #f1f5f9; }
.state.locked { color: #be123c; background: #fff1f2; margin-left: 6px; }
.led.ok { color: var(--green); } .led.warn { color: var(--orange); } .led.muted { color: var(--gray); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px;
  background: #f1f4f9; color: #475569; font-size: 12px; font-weight: 500;
}
a.chip:hover { background: #e7ecf5; }
.chip.on { background: var(--text); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--green); color: #fff; font-size: 12px; font-weight: 700;
}
.forever { display: inline-flex; align-items: center; gap: 5px; color: var(--blue); font-weight: 600; }
.type {
  font-family: var(--mono); font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: #f1f5f9; color: #475569;
}
.t-string { background: #eef2ff; color: #4338ca; }
.t-hash { background: #ecfdf5; color: #047857; }
.t-list { background: #fff7ed; color: #c2410c; }
.t-set { background: #fdf2f8; color: #be185d; }
.t-zset { background: #f5f3ff; color: #6d28d9; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-right: 4px; }
.tag.pk { background: #fef3c7; color: #92400e; }
.tag.nn { background: #f1f5f9; color: #475569; }
.tag.uq { background: #ede9fe; color: #5b21b6; }

/* 筛选栏 */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; min-width: 260px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.search input { border: none; outline: none; background: none; flex: 1; font: inherit; color: var(--text); padding: 0; height: auto; }
.bar { display: flex; justify-content: space-between; align-items: center; }
.bar form { margin: 0; }
.hint { margin: -6px 0 0; font-size: 12px; }

/* 表单 */
input, select {
  font: inherit; color: var(--text); height: 38px; padding: 0 16px; width: 100%;
  border: 1px solid var(--line); border-radius: 999px; background: #fbfcfe; outline: none;
}
select { padding-right: 34px; appearance: none;
  background: #fbfcfe url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center; }
.filters select { width: auto; background-color: var(--card); }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #4f7cff22; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #4b5563; font-weight: 500; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.req { font-style: normal; font-size: 11px; color: var(--red); background: #fff1f2; padding: 1px 8px; border-radius: 999px; margin-left: 4px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline input { width: 160px; }
.gap-top { margin-top: 12px; }

/* 过期选项：椭圆分段 */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; display: block; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
  display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fbfcfe; font-size: 13px; font-weight: 500; color: #4b5563; transition: all .12s;
}
.seg input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px #4f7cff33; }
.custom-at { display: none; margin-top: 4px; }
.seg:has(input[value="custom"]:checked) + .custom-at { display: block; }
.tenant-new { display: none; }
.tenant-pick:has(option[value="__new__"]:checked) + .tenant-new { display: block; }

/* 弹出层 */
.drawer { position: relative; }
.drawer > .card { position: absolute; right: 0; top: 46px; width: 460px; z-index: 20; box-shadow: 0 18px 50px #1f293722; }
.pop { position: relative; }
.pop > .card { position: absolute; right: 0; top: 40px; width: 330px; z-index: 30; box-shadow: 0 18px 50px #1f293726; text-align: left; }
.pop[open] > summary { background: var(--c); color: #fff; }

/* 提示条 */
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  font-weight: 500; animation: drop .25s ease-out;
}
.toast.ok { background: #e7f8f0; color: #0f7a51; }
.toast.ok .dot { background: var(--green); color: #fff; }
.toast.bad { background: #fff1f2; color: #be123c; }
.toast.bad .dot { background: var(--red); color: #fff; }
.toast.warn { background: #fef3e2; color: #92400e; border-radius: var(--radius); }
.toast.warn .dot { background: var(--orange); color: #fff; }
.toast.fade { opacity: 0; transition: opacity .5s; }
@keyframes drop { from { transform: translateY(-6px); opacity: 0; } }

/* 新密钥 */
.reveal { display: flex; align-items: center; gap: 16px; border-color: color-mix(in srgb, var(--purple) 40%, white); background: #faf8ff; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.secret { font-size: 16px; padding: 6px 16px; align-self: flex-start; background: #fff; border: 1px dashed var(--purple); color: #5b21b6; user-select: all; }

/* 数据库 */
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tcard { display: flex; flex-direction: column; gap: 14px; transition: border-color .15s; }
.tcard:hover { border-color: #b9c6e4; }
.thead { display: flex; align-items: center; gap: 12px; }
.thead b { font-size: 16px; display: block; }
.cols { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cols li { display: flex; align-items: center; gap: 8px; }
.cols li .mono { flex: 1; }
.code {
  margin: 0; padding: 16px 20px; background: #0f172a; color: #e2e8f0; border-radius: 14px;
  font: 13px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; overflow: auto; max-height: 520px;
}
.card.flush > .code { margin: 8px 20px 20px; }
.keylink:hover { color: var(--blue); }

/* 登录页 */
.login-body { align-items: center; justify-content: center; }
.login { width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; padding: 34px 30px; }
.login p { margin: -6px 0 6px; }

.htmx-request main { opacity: .6; transition: opacity .2s .1s; }

/* 窄屏：侧栏只留圆形图标。表格卡片不设 overflow，否则行内弹出层会被裁掉 */
@media (max-width: 900px) {
  .side { width: 64px; padding: 18px 8px; align-items: center; }
  .brand > span:last-child { display: none; }
  .side nav a, .logout .pill { font-size: 0; gap: 0; padding: 4px; justify-content: center; }
  .logout .pill { width: 40px; height: 40px; }
  main { padding: 18px 16px 40px; }
  .head { flex-wrap: wrap; }
  .drawer > .card { width: min(460px, calc(100vw - 100px)); }
  .search { min-width: 0; flex: 1; }
  .grid2.wide-left, .form .row { grid-template-columns: 1fr; }
}
