:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Microsoft YaHei", sans-serif;
    color: #334155;
    background: #f0f2f5;
    font-size: 15px;
    --xhs-red: #ff2442;
    --xhs-red-hover: #e11d48;
    --xhs-red-light: #fff1f2;
    --border-color: #e2e8f0;
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
button, input, textarea { font: inherit; }
button { cursor: pointer; transition: all 0.2s ease; }

.app-shell { width: min(100% - 32px, 720px); margin: 32px auto; display: flex; flex-direction: column; gap: 20px; }
.loading { text-align: center; color: #64748b; font-weight: bold; margin-top: 100px; }

/* 认证界面样式 */
.auth-layout { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 20px 0; }
.auth-panel { width: min(100%, 400px); padding: 32px; background: #fff; border: 1px solid var(--border-color); border-radius: 24px; box-shadow: var(--shadow-md); position: relative; overflow: hidden; }
.auth-panel::before { content: ''; position: absolute; top: 0; right: 0; width: 120px; height: 120px; background: var(--xhs-red-light); border-radius: 50%; transform: translate(40px, -40px); opacity: 0.6; z-index: 0; }

.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; position: relative; z-index: 1; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--xhs-red) 0%, #ff6b81 100%); color: #fff; font-weight: 900; font-size: 20px; box-shadow: 0 8px 16px rgba(255, 36, 66, 0.2); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 800; color: #1e293b; }
.brand p { margin: 2px 0 0; font-size: 12px; color: #64748b; font-weight: 600; letter-spacing: 0.05em; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 24px; border-bottom: 1px solid var(--border-color); position: relative; z-index: 1; }
.tab { padding: 12px; border: 0; background: transparent; color: #64748b; font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--xhs-red); border-bottom-color: var(--xhs-red); font-weight: 800; }

.form-grid { display: grid; gap: 16px; position: relative; z-index: 1; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #475569; }

input, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 12px 16px; color: #1e293b; background: #fff; transition: all 0.2s ease; }
input:focus, textarea:focus { outline: none; border-color: var(--xhs-red); box-shadow: 0 0 0 3px rgba(255, 36, 66, 0.1); }
textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

/* 按钮基础样式 */
.btn { border: 1px solid transparent; border-radius: 12px; padding: 12px 20px; font-weight: 700; font-size: 14px; text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--xhs-red); color: #fff; box-shadow: 0 4px 10px rgba(255, 36, 66, 0.15); }
.btn-primary:hover:not(:disabled) { background: var(--xhs-red-hover); box-shadow: 0 6px 15px rgba(255, 36, 66, 0.25); }
.btn-secondary { background: #fff; color: #475569; border-color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; border-color: #94a3b8; }
.btn-danger { color: #dc2626; background: #fff; border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: #fff5f5; }
.btn-small { padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* 主界面导航与头部 */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px; background: #fff; border: 1px solid var(--border-color); border-radius: 20px; box-shadow: var(--shadow-sm); }
.identity { display: grid; gap: 4px; }
.identity strong { font-size: 20px; font-weight: 800; color: #1e293b; }
.identity span { font-size: 13px; color: #64748b; font-weight: 500; }
.status { color: #16a34a; font-weight: 700; }
.status.expired { color: #dc2626; }
.topbar > .actions { display: flex; gap: 8px; }

/* 卡片排版 */
.stack { display: flex; flex-direction: column; gap: 20px; }
.panel { padding: 24px; background: #fff; border: 1px solid var(--border-color); border-radius: 24px; box-shadow: var(--shadow-sm); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-header h2 { font-size: 16px; font-weight: 800; color: #1e293b; margin: 0; position: relative; padding-left: 12px; }
.panel-header h2::before { content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; background: var(--xhs-red); border-radius: 2px; }
.panel-header .muted { font-size: 13px; font-weight: 600; color: #64748b; background: #f1f5f9; padding: 4px 10px; border-radius: 20px; }

/* 链接行与列表 */
.link-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-height: 380px; overflow-y: auto; padding-right: 4px; }
.link-list::-webkit-scrollbar { width: 6px; }
.link-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; background: #f8fafc; border: 1px solid var(--border-color); border-radius: 12px; transition: all 0.2s ease; }
.link-row:hover { background: #f1f5f9; }
.link-row a { overflow: hidden; color: #2563eb; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-size: 13px; }
.link-row a:hover { text-decoration: underline; color: #1d4ed8; }

.empty { margin: 24px 0 0; color: #64748b; text-align: center; font-size: 13px; padding: 32px 0; background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: 16px; font-weight: 500; }

/* 设备数量状态条 */
.device-banner { display: flex; align-items: center; justify-content: space-between; background: var(--xhs-red-light); border: 1px solid #fee2e2; padding: 10px 16px; border-radius: 12px; font-size: 13px; color: #991b1b; font-weight: 600; margin-top: 10px; }
.device-banner button { background: #fff; border: 1px solid #fca5a5; color: #b91c1c; font-weight: bold; border-radius: 6px; padding: 4px 8px; font-size: 11px; }
.device-banner button:hover { background: #fef2f2; }

/* 执行引擎面板 */
.execution { display: none; margin-top: 16px; padding: 20px; background: var(--xhs-red-light); border: 1px solid #fee2e2; border-radius: 16px; box-shadow: var(--shadow-sm); animation: fadeIn 0.3s ease; }
.execution.active { display: grid; gap: 12px; }
.execution #progress { font-size: 12px; text-transform: uppercase; font-weight: 800; color: var(--xhs-red); letter-spacing: 0.05em; }
.execution strong { word-break: break-all; font-size: 14px; color: #1e293b; background: #fff; padding: 12px; border: 1px solid #fee2e2; border-radius: 10px; font-weight: 600; }

/* 提示信息弹窗 */
.notice { position: fixed; z-index: 1000; top: 24px; left: 50%; transform: translate(-50%, -20px); width: min(calc(100% - 32px), 420px); padding: 14px 20px; border-radius: 16px; color: #fff; background: #1e293b; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); display: flex; align-items: center; justify-content: center; gap: 8px; animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.notice.error { background: #dc2626; }
.notice.success { background: #15803d; }

@keyframes slideDown {
    to { transform: translate(-50%, 0); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .app-shell { width: min(100% - 20px, 720px); margin: 20px auto; gap: 16px; }
    .auth-layout { min-height: calc(100vh - 40px); }
    .auth-panel { padding: 24px; }
    .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
    .topbar > .actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
}
