/* 授权管理页。颜色、圆角、字体和控件沿用客户端面板（client/taobao_manager/static/index.html）。 */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --line: #e3e5ea; --text: #1c1f26; --muted: #596070;
  --accent: #2748d6; --accent-soft: #e8edff; --ok: #0e6b4c; --ok-soft: #e2f5ee;
  --warn: #8f4a05; --warn-soft: #fdf0dc; --bad: #b02f26; --bad-soft: #fde8e6;
  --on-accent: #ffffff; --on-bad: #ffffff;
  --radius: 10px; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1d2026; --line: #2c3038; --text: #e7e9ee; --muted: #9299a6;
    --accent: #7b96ff; --accent-soft: #252d4a; --ok: #4fc79c; --ok-soft: #173329;
    --warn: #e6a550; --warn-soft: #3a2c15; --bad: #f08379; --bad-soft: #40201d;
    --on-accent: #0f1320; --on-bad: #2a0d0a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { accent-color: var(--accent); caret-color: var(--accent); }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; }
::selection { background: var(--accent-soft); color: var(--text); }
::placeholder { color: var(--muted); opacity: 1; }
a { color: var(--accent); text-underline-offset: 3px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--bg); border-radius: 4px; padding: 1px 5px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.form-error { color: var(--bad); margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 控件 */
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 6px 13px; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s, background-color .15s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.1); color: var(--on-accent); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn.bad:hover { filter: brightness(1.08); color: var(--on-bad); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.link { border-color: transparent; background: transparent; color: var(--muted); padding: 1px 6px; font-size: 12px; }
.btn.link:hover { color: var(--accent); border-color: transparent; }
.btn:disabled { opacity: .55; cursor: wait; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  font: inherit; width: 100%; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled, select:disabled { color: var(--muted); background: var(--bg); }
input[aria-invalid=true] { border-color: var(--bad); }
.field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { width: 16px; height: 16px; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 2px 10px;
  font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.plain::before { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 99px; padding: 3px 12px; cursor: pointer; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip .n { margin-left: 5px; font-variant-numeric: tabular-nums; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.banner { border-radius: 8px; padding: 9px 12px; margin: 0 0 12px; background: var(--warn-soft); color: var(--warn);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

/* 登录 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; padding: 24px 26px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card h1 small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.login-card .btn.primary { justify-self: start; padding: 7px 20px; }

/* 主界面 */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand small { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--muted); }
.top .sp { flex: 1; }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start;
  max-width: 1600px; margin: 0 auto; padding: 18px 24px 60px; }

.gen { position: sticky; top: 68px; max-height: calc(100vh - 86px); overflow: auto; }
.gen-form { display: grid; gap: 12px; }
.gen-submit { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.gen-submit .btn { padding-inline: 20px; }
.gen-result { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.gen-summary { margin: 0; }
.gen-summary b { font-weight: 600; }
.gen-result textarea { min-height: 120px; max-height: 260px; resize: vertical; line-height: 1.7; white-space: pre; }

.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head h2 { margin: 0; flex: 1; }
.list-head input { width: 240px; }

.tablewrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
.keys tr.item { cursor: pointer; transition: background-color .15s; }
.keys tr.item:hover { background: var(--bg); }
.keys tr.item.open { background: var(--accent-soft); }
.keys tr.item.open td { border-bottom-color: transparent; }
.keys tr.item.fresh { animation: fresh 2.6s var(--ease); }
@keyframes fresh { from { background-color: var(--accent-soft); } }
.keys .key { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.keys .when { white-space: nowrap; }
.keys .when small, .keys .sub { display: block; color: var(--muted); font-size: 12px; }
/* 备注列吃掉剩下的宽度、放不下就截断，不把表格撑出横向滚动（max-width: 0 是表格单元格的老办法） */
.keys td.note-cell { max-width: 0; width: 30%; }
.keys .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys .online-on { color: var(--ok); font-weight: 600; }
.keys .online-off { color: var(--muted); }
.keys td.op { text-align: right; width: 1%; }
.keys tbody tr:last-child td { border-bottom: 0; }
.skeleton td span { display: block; height: 10px; border-radius: 5px; background: var(--line); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; } }
.empty { color: var(--muted); text-align: center; padding: 32px 0 20px; display: grid; gap: 10px; justify-items: center; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 12px; color: var(--muted); font-size: 12px; }

/* 行内详情 */
.keys tr.detail > td { background: var(--bg); padding: 16px 18px 18px; border-bottom: 1px solid var(--line); cursor: default; }
.detail-body { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 24px; align-items: start;
  animation: reveal .2s var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }
.detail-form { display: grid; gap: 12px; }
.detail-form .extend { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.detail-meta { margin: 0; color: var(--muted); font-size: 12px; display: grid; gap: 2px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; justify-items: start; }
.danger-zone p { margin: 0; color: var(--bad); }
.devices h3 { font-size: 13px; margin: 0; flex: 1; }
.devices-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.devices table { font-size: 13px; }
.devices th, .devices td { padding: 6px 8px; }
.devices td.device-cell { max-width: 0; width: 40%; }
.devices .device-name, .devices .device-id { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.devices .device-id { color: var(--muted); }
.devices .hint { margin-top: 8px; }
.detail-msg { padding: 6px 0; color: var(--muted); }

#toast { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
#toast div { background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px; max-width: 420px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18); animation: reveal .2s var(--ease); }
#toast div.bad { background: var(--bad); color: var(--on-bad); }

/* 窄屏：生成栏放到列表上面，表单字段横排 */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .gen { position: static; max-height: none; overflow: visible; }
  .gen-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
  .gen-form .wide { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .detail-body { grid-template-columns: minmax(0, 1fr); }
  .detail-form { max-width: 480px; }
}
@media (max-width: 640px) {
  .top { padding: 10px 14px; }
  .brand small { display: none; }
  .layout { padding: 12px 12px 40px; gap: 12px; }
  .card { padding: 14px; }
  .list-head { flex-wrap: wrap; }
  .list-head input { width: 100%; }
  #toast { left: 12px; right: 12px; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
