/* Lunath 授权系统 - 统一设计系统
   风格：简约、留白充足、单色线性图标、无括号标签 */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e6e9ef;
  --border-strong: #d7dce5;
  --text: #1f2329;
  --text-2: #5b6470;
  --muted: #98a1af;
  --brand: #1f2329;
  --brand-strong: #000000;
  --brand-soft: #eef1f4;
  --accent: #3370ff;
  --accent-soft: #eef3ff;
  --ok: #17a673;
  --ok-soft: #e8f7f0;
  --danger: #e34d59;
  --danger-soft: #fdeef0;
  --warn: #d98700;
  --warn-soft: #fdf3e2;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 35, 41, .04), 0 6px 20px rgba(31, 35, 41, .05);
  --sidebar: 216px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d3d8e0; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 通用元素 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f3c6ca; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f2f4f7; }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 35, 41, .1);
}
.input:disabled, .select:disabled { background: #f7f8fa; color: var(--muted); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%2398a1af' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

.field { margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.field-hint { margin-top: 6px; color: var(--muted); font-size: 12px; }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row .input, .field-row .select { flex: 1 1 auto; min-width: 0; }
/* field-row 内按钮与输入框等高、垂直居中，不被拉伸 */
.field-row .btn { flex: 0 0 auto; height: 36px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 15px; font-weight: 600; }
.card-desc { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  background: #f2f4f7;
  color: var(--text-2);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 500;
  color: var(--text-2);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; align-items: center; }
/* 行内复选框 */
.table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

/* 批量操作栏 */
.batch-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
}
.batch-bar > span { font-size: 13px; color: var(--accent); font-weight: 500; white-space: nowrap; }
.batch-bar .grow { flex: 1; }

/* 开关行（全局配置通知开关） */
.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row span { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.switch { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; position: relative; border-radius: 999px; background: #d7dce5; cursor: pointer; transition: background .15s ease; flex-shrink: 0; margin: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 16px; }
/* 长文本：单行截断 + 悬停（title 属性）显示完整内容，避免撑高行/错位 */
.truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-email .truncate { max-width: 220px; }
.cell-file .truncate { max-width: 180px; }
.cell-secret .truncate { max-width: 280px; }
.cell-note .truncate { max-width: 240px; }
/* 卡密密文：唯一蓝色点缀 */
.secret { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.pager-actions { display: flex; gap: 8px; align-items: center; }

.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: #1f2329;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  animation: toast-in .2s ease;
}
.toast-ok { background: #17a673; }
.toast-err { background: #e34d59; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(31, 35, 41, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .15s ease;
}
/* 关键：恢复 HTML hidden 属性——否则带 hidden 的弹窗会被 display:flex 覆盖而一直显示 */
.modal-mask[hidden] { display: none !important; }
/* 通用：任何带 hidden 属性的元素都强制隐藏（注册视图等依赖此规则可靠隐藏） */
[hidden] { display: none !important; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto;
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  animation: pop .18s ease;
}
.modal-lg { max-width: 760px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { width: 28px; height: 28px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; font-size: 18px; line-height: 1; }
.modal-close:hover { background: #f2f4f7; color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* 列表型信息 */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.divider { height: 1px; background: var(--border); margin: 18px 0; }
.section-title { margin: 0 0 12px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.break-all { word-break: break-all; }

/* 拖拽上传区 */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 20px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; background: #fafbfc; transition: all .15s ease; }
.dropzone:hover { border-color: var(--brand); color: var(--text-2); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ============ 认证页 ============ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; font-size: 18px; font-weight: 600; }
.auth-title { margin: 14px 0 4px; font-size: 19px; font-weight: 600; }
.auth-sub { margin: 0; color: var(--muted); font-size: 13px; }
.auth-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: #eceff3; border-radius: var(--radius-sm); }
.auth-tab { flex: 1; height: 32px; border: none; background: transparent; border-radius: 4px; color: var(--text-2); font-size: 13.5px; cursor: pointer; font-family: inherit; }
.auth-tab.active { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.auth-foot { margin-top: 16px; display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); }
.auth-foot a { color: var(--brand); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
.code-tip { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
/* 输入框单位后缀（Hz / ms） */
.field-row .unit-tag { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 0 12px; height: 38px; border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: #f2f3f5; color: var(--muted); font-size: 13px; font-weight: 500; user-select: none; }
.field-row .input:not(:last-child) { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* 客户端首页 */
.announce-text { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.9; color: var(--text); }
.home-links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.home-link-btn { padding: 10px 28px; font-size: 14px; }
/* 撑满模式：按钮平分快捷入口卡片宽度（仅该小板块，非全屏），文字居中，名称过长省略 */
.home-links.fill { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; align-items: stretch; }
.home-links.fill .home-link-btn { width: 100%; padding: 10px 12px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 管理端：自定义链接编辑行 */
.link-row { display: flex; gap: 8px; margin-bottom: 8px; }
.link-row .input { flex: 1; min-width: 0; }
.link-row .btn { flex-shrink: 0; }
.code-box-tip { font-size: 12.5px; color: var(--text); }
.code-box-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: 3px; color: var(--brand); }

/* ============ 客户端 ============ */
.site { min-height: 100vh; display: flex; flex-direction: column; }
.site-head { height: 58px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; }
.site-logo { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.site-logo .mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 13px; }
.site-head .spacer { flex: 1; }
.site-nav { display: flex; gap: 4px; }
.site-nav button { height: 32px; padding: 0 14px; border: none; background: transparent; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; cursor: pointer; font-family: inherit; }
.site-nav button:hover { background: #f2f4f7; color: var(--text); }
.site-nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.site-main { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 24px; }
.page-title { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.page-desc { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.info-list { display: flex; flex-direction: column; }
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid #f0f2f5; font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--muted); flex-shrink: 0; }
.info-row .v { text-align: right; word-break: break-all; }
.pwd-mask { letter-spacing: 2px; cursor: pointer; user-select: none; color: var(--text); }
.pwd-mask.revealed { letter-spacing: normal; font-family: ui-monospace, Menlo, Consolas, monospace; }

.token-box { margin-top: 16px; padding: 14px; border-radius: var(--radius-sm); background: #f7f9fc; border: 1px solid var(--border); }
.token-box .label { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.token-value { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

/* ============ 管理端 ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); flex-shrink: 0; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 18px; border-bottom: 1px solid var(--border); font-size: 14.5px; font-weight: 600; }
.sidebar-brand .mark { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; font-size: 12px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav button {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px;
  border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; cursor: pointer; text-align: left; font-family: inherit;
}
.sidebar-nav button:hover { background: #f4f6f8; color: var(--text); }
.sidebar-nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.sidebar-nav button[data-panel="cards"].active { background: var(--accent-soft); color: var(--accent); }
.sidebar-nav svg { flex-shrink: 0; opacity: .9; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 58px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.content { flex: 1; padding: 20px 24px 40px; overflow-x: hidden; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { margin-top: 6px; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .input, .toolbar .select { height: 34px; }
.toolbar .w-input { width: 220px; }
.toolbar .w-select { width: 130px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; color: var(--text-2); font-size: 13px; cursor: pointer; font-family: inherit; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.code-list { max-height: 260px; overflow: auto; padding: 12px; border-radius: var(--radius-sm); background: #f7f9fc; border: 1px solid var(--border); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.9; word-break: break-all; }

.detail-block { margin-bottom: 22px; }
.detail-block:last-child { margin-bottom: 0; }

.log-list { max-height: 420px; overflow: auto; }
.log-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.log-row:last-child { border-bottom: none; }
.log-time { flex-shrink: 0; width: 140px; color: var(--muted); font-size: 12.5px; }

/* ===== 账号详情：参数文件板块 ===== */
.param-list { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow: auto; }
.param-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; }
.param-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.param-block-file { font-weight: 600; font-size: 14px; min-width: 0; }
.param-block-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-size: 12.5px; }
.param-block-note { margin-top: 8px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; color: var(--text-2); }
.param-block-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* ===== 账号详情：授权记录板块 ===== */
.auth-list { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.auth-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: #fafbfc; }
.auth-block-head { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; font-size: 13px; }
.auth-label { color: var(--muted); font-size: 12.5px; }
.auth-label::after { content: '：'; }
.auth-value { font-weight: 600; word-break: break-all; }
.auth-block-time { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.auth-value.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.auth-value.truncate { max-width: 560px; white-space: normal; word-break: break-all; overflow-wrap: anywhere; overflow: visible; text-overflow: clip; }

@media (max-width: 640px) {
  .auth-value.truncate { max-width: 300px; }
}
.log-text { flex: 1; word-break: break-all; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar-brand { border-bottom: none; border-right: 1px solid var(--border); }
  .sidebar-nav { flex-direction: row; padding: 8px 10px; }
  .sidebar-nav button { height: 34px; padding: 0 12px; }
  .sidebar-nav button span { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 16px; }
  .site-main { padding: 16px; }
  .site-head { padding: 0 16px; }
  .kv { grid-template-columns: 84px 1fr; }
  .batch-bar { flex-wrap: wrap; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .w-input, .toolbar .w-select { width: auto; flex: 1 1 120px; }
  .row-actions { flex-wrap: wrap; }
}
