* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f8f6;
  --card: #ffffff;
  --line: #e6ece9;
  --ink: #1f2937;
  --ink2: #5b6770;
  --ink3: #9aa6a0;
  --brand: #10b981;
  --brand-dark: #059669;
  --brand-soft: #d9f5ea;
  --blue: #2563eb; --blue-soft: #dbeafe;
  --green: #16a34a; --green-soft: #dcfce7;
  --red: #dc2626; --red-soft: #fee2e2;
  --amber: #b45309; --amber-soft: #fef3c7;
  --gray: #6b7280; --gray-soft: #f1f5f3;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 2px 8px rgba(15,23,42,.05);
  --shadow-lg: 0 8px 30px rgba(15,23,42,.12);
  --radius: 12px;
}
body { font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eafaf3 0%, #e7f4fb 55%, #eef2fc 100%); }
.login-card { background: var(--card); padding: 40px 42px; border-radius: 18px; width: 380px; box-shadow: var(--shadow-lg); border: 1px solid rgba(16,185,129,.08); }
.login-logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; }
.login-logo svg { width: 28px; height: 28px; }
.login-card h1 { font-size: 22px; text-align: center; color: var(--ink); }
.login-card .subtitle { text-align: center; color: var(--ink2); margin: 6px 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--ink2); margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fbfdfc; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,.14); background: #fff; }
.btn-primary { width: 100%; padding: 12px; background: var(--brand); color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 10px; transition: background .15s; }
.btn-primary:hover { background: var(--brand-dark); }

/* ===== 布局 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--card); color: var(--ink2); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid var(--line); overflow: hidden; transition: width .2s ease; }
.sidebar .brand { padding: 18px 16px; display: flex; align-items: center; gap: 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-logo svg { width: 18px; height: 18px; }
.sidebar .brand .brand-name { flex: 1; font-size: 15px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
#sidebar-toggle { background: none; border: none; color: var(--ink3); cursor: pointer; font-size: 15px; padding: 4px 8px; line-height: 1; flex-shrink: 0; border-radius: 8px; }
#sidebar-toggle:hover { background: var(--gray-soft); color: var(--ink); }
.sidebar nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 10px; border-radius: 10px; color: var(--ink2); text-decoration: none; font-size: 14px; white-space: nowrap; transition: background .12s, color .12s; }
.sidebar nav a .nav-ico { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--gray-soft); color: var(--ink); }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.user-box { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.user-box span { display: block; margin-bottom: 8px; color: var(--ink); font-weight: 600; }
.link-btn { background: none; border: none; color: var(--brand-dark); cursor: pointer; font-size: 13px; margin-right: 12px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
/* 登录页保持登录勾选 */
.login-remember { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink2); cursor: pointer; margin: 14px 0 0 !important; }
.login-remember input { width: auto; margin: 0; accent-color: var(--brand); }
.login-remember span { line-height: 1.4; }
/* 收纳态底部的退出按钮 */
.logout-collapsed { display: none; margin: 0 auto 14px; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); cursor: pointer; align-items: center; justify-content: center; flex-shrink: 0; }
.logout-collapsed svg { width: 17px; height: 17px; }
.logout-collapsed:hover { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.sidebar.collapsed .logout-collapsed { display: flex; }

/* 收纳状态：图标在上、文字在下 */
.sidebar.collapsed { width: 78px; }
.sidebar.collapsed .brand { padding: 14px 0; justify-content: center; }
.sidebar.collapsed .brand-logo, .sidebar.collapsed .brand-name { display: none; }
.sidebar.collapsed nav a { flex-direction: column; gap: 3px; padding: 9px 2px; margin: 2px 8px; }
.sidebar.collapsed nav a .nav-ico { width: 22px; height: 22px; }
.sidebar.collapsed nav a .nav-txt { font-size: 10px; }
.sidebar.collapsed .user-box { display: none; }

.content { flex: 1; padding: 24px; overflow-x: auto; }
.page h2 { font-size: 18px; margin-bottom: 16px; color: var(--ink); }

/* 工作台 iframe */
#page-workbench { margin: -24px; height: 100vh; overflow: hidden; }
#page-workbench iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ASIN 运营中心 iframe */
#page-asinops { margin: -24px; height: 100vh; overflow: hidden; }
#page-asinops iframe { width: 100%; height: 100%; border: 0; display: block; }

/* 广告分析 iframe */
#page-adanalysis { margin: -24px; height: 100vh; overflow: hidden; }
#page-adanalysis iframe { width: 100%; height: 100%; border: 0; display: block; }

/* 排版工具 iframe */
#page-labeltool { margin: -24px; height: 100vh; overflow: hidden; }
#page-labeltool iframe { width: 100%; height: 100%; border: 0; display: block; }

/* 资料库 iframe */
#page-labels { margin: -24px; height: 100vh; overflow: hidden; }
#page-labels iframe { width: 100%; height: 100%; border: 0; display: block; }

/* 关键词调研 iframe */
#page-kwresearch { margin: -24px; height: 100vh; overflow: hidden; }
#page-kwresearch iframe { width: 100%; height: 100%; border: 0; display: block; }

/* 选品中心 iframe */
#page-selection { margin: -24px; height: 100vh; overflow: hidden; }
#page-selection iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ===== AI 助手 ===== */
#page-aiassistant { margin: -24px; height: 100vh; overflow: hidden; }
.chat-wrap { display: flex; height: 100%; }
.chat-sidebar { width: 240px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; }
.chat-sidebar #chat-new { width: 100%; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.conv-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--ink2); font-size: 13px; transition: background .12s; }
.conv-item:hover { background: var(--gray-soft); }
.conv-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del { flex-shrink: 0; width: 22px; height: 22px; border: none; background: transparent; color: var(--ink3); font-size: 15px; line-height: 1; border-radius: 6px; cursor: pointer; display: none; }
.conv-item:hover .conv-del { display: flex; align-items: center; justify-content: center; }
.conv-del:hover { background: var(--red-soft); color: var(--red); }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.chat-head h2 { font-size: 17px; margin: 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.chat-empty { text-align: center; color: var(--ink3); margin: auto; font-size: 13px; }
.msg { max-width: 72%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg .m-time { display: block; font-size: 10px; margin-top: 5px; opacity: .75; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-bottom-left-radius: 4px; color: var(--ink); }
.msg.ai .m-time { color: var(--ink3); }
.chat-inputbar { display: flex; gap: 10px; padding: 14px 24px 18px; background: var(--card); border-top: 1px solid var(--line); }
.chat-inputbar textarea { flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; background: #fbfdfc; color: var(--ink); line-height: 1.5; }
.chat-inputbar textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,.12); background: #fff; }
#chat-send { align-self: flex-end; padding: 10px 24px; border-radius: 10px; }
.chat-sidebar #chat-skills { width: 100%; }
.chat-head-actions { display: flex; gap: 8px; align-items: center; }
#chat-file-btn { align-self: flex-end; padding: 10px 12px; border-radius: 10px; font-size: 15px; }
.msg.file-msg { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.skill-check { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; background: var(--card); }
.skill-check input { width: auto; margin-top: 3px; accent-color: var(--brand); }
.skill-check b { font-size: 13px; color: var(--ink); }
.skill-check .skill-desc { display: block; }
.skill-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.skill-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--card); }
.skill-info { flex: 1; min-width: 0; }
.skill-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.skill-desc { font-size: 12px; color: var(--ink2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 用户表单：店铺分配区 */
.user-form-tip { font-size: 12px; color: var(--ink3); margin: 10px 0 0; line-height: 1.6; }
.lx-store-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.lx-store-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.lx-select-all { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); cursor: pointer; }
.lx-select-all input { width: auto; accent-color: var(--brand); }
.lx-store-box { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fbfdfc; }
.lx-store-box .skill-check { margin-bottom: 4px; background: var(--card); }
.lx-store-box .skill-check:last-child { margin-bottom: 0; }
.lx-store-hint { font-size: 11px; color: var(--ink3); margin: 6px 0 0; line-height: 1.5; }
/* 店铺选项行：名称在左半边居中放大加粗，勾选框在右半边居中 */
.lx-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; margin-bottom: 4px; transition: border-color .12s; }
.lx-row:hover { border-color: var(--brand); }
.lx-row:last-child { margin-bottom: 0; }
.lx-row-name { text-align: center; font-size: 15px; font-weight: 700; color: var(--ink); }
.lx-row input { justify-self: center; width: 17px; height: 17px; accent-color: var(--brand); }
/* 用户列表行内角色下拉 */
.role-inline { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fbfdfc; color: var(--ink); cursor: pointer; }
.role-inline:focus { outline: none; border-color: var(--brand); }
.role-inline:disabled { cursor: not-allowed; opacity: .6; }
/* 用户列表行内领星店铺多选下拉 */
.lx-multi { position: relative; }
.lx-multi-btn { padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfc; color: var(--ink); font-size: 12px; cursor: pointer; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.lx-multi-btn:hover { border-color: var(--brand); }
.lx-multi-panel { position: fixed; z-index: 200; width: 280px; max-height: 300px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px; display: none; }
.lx-multi-panel.show { display: block; }
.lx-multi-title { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.lx-multi-panel .skill-check { margin-bottom: 4px; }
.lx-multi-panel .skill-check:last-child { margin-bottom: 0; }
.skill-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== 统计卡片 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--brand-dark); }
.stat-card .lbl { font-size: 13px; color: var(--ink2); margin-top: 4px; }

/* ===== 工具条 & 表格 ===== */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fbfdfc; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,.12); background: #fff; }
.btn { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 14px; transition: all .12s; }
.btn:hover { background: var(--gray-soft); border-color: #d3dcd7; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; font-size: 14px; border-bottom: 1px solid #f0f4f2; white-space: nowrap; }
th { background: #f8fbf9; color: var(--ink2); font-weight: 600; font-size: 13px; }
tr:hover td { background: #fafcfb; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--gray-soft); color: var(--gray); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.purple { background: #ede9fe; color: #6d28d9; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-card { background: var(--card); border-radius: 16px; width: 540px; max-width: 92vw; max-height: 85vh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow-lg); }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-card label { display: block; font-size: 13px; color: var(--ink2); margin: 12px 0 6px; }
.modal-card input, .modal-card select, .modal-card textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fbfdfc; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,.12); background: #fff; }
.modal-card .error { margin: 4px 0 0; }
/* 弹窗内店铺行：覆盖 .modal-card label/input 的默认样式，恢复两栏布局 */
.modal-card label.lx-row { display: grid; grid-template-columns: 1fr 1fr; align-items: center; margin: 0 0 4px; color: var(--ink); }
.modal-card label.lx-row:last-child { margin-bottom: 0; }
.modal-card .lx-row-name { font-size: 15px; font-weight: 700; text-align: center; color: var(--ink); }
.modal-card .lx-row input { width: 17px; height: 17px; padding: 0; margin: 0; border: none; border-radius: 0; background: transparent; justify-self: center; box-shadow: none; }
.btn-plain { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); cursor: pointer; font-size: 14px; }
.btn-plain:hover { background: var(--gray-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ===== 手机端：主框架、导航、AI 助手、用户管理 ===== */
@media (max-width: 720px) {
  html, body { width: 100%; min-height: 100%; overflow-x: hidden; }
  body { padding-bottom: env(safe-area-inset-bottom); }

  .login-wrap { min-height: 100dvh; padding: 18px 14px; align-items: center; }
  .login-card { width: 100%; max-width: 390px; padding: 28px 22px; border-radius: 16px; }
  .login-card input, .login-card .btn-primary { min-height: 46px; font-size: 16px; }

  .app { min-height: 100dvh; display: block; }
  .sidebar, .sidebar.collapsed {
    position: fixed; inset: auto 0 0; z-index: 80;
    width: 100%; height: calc(64px + env(safe-area-inset-bottom));
    border: 0; border-top: 1px solid var(--line); overflow: visible;
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -3px 14px rgba(15,23,42,.08);
  }
  .sidebar .brand, .sidebar.collapsed .brand, .logout-collapsed, .sidebar.collapsed .logout-collapsed { display: none; }
  .sidebar nav, .sidebar.collapsed nav {
    display: flex; align-items: stretch;
    width: 100%; height: 64px; padding: 5px 4px; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar, .sidebar.collapsed nav::-webkit-scrollbar { display: none; }
  .sidebar nav a, .sidebar.collapsed nav a {
    flex: 0 0 auto; width: 62px; min-width: 62px;
    min-height: 54px; margin: 0; padding: 5px 2px;
    flex-direction: column; justify-content: center; gap: 2px; border-radius: 9px;
  }
  .sidebar nav a:last-child, .sidebar.collapsed nav a:last-child { margin-right: 4px; }
  .sidebar nav a .nav-ico, .sidebar.collapsed nav a .nav-ico { width: 22px; height: 22px; }
  .sidebar nav a .nav-txt, .sidebar.collapsed nav a .nav-txt {
    width: 100%; overflow: hidden; text-overflow: ellipsis; text-align: center; font-size: 10px;
  }
  .user-box, .sidebar.collapsed .user-box {
    position: fixed; inset: 0 0 auto; z-index: 79; height: 50px;
    padding: 7px 12px; border: 0; border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
    display: flex; align-items: center; gap: 5px; box-shadow: 0 1px 8px rgba(15,23,42,.05);
  }
  .user-box span { display: block; flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .link-btn { min-height: 36px; margin: 0; padding: 7px 9px; border-radius: 8px; background: var(--gray-soft); }

  .content { width: 100%; height: 100dvh; padding: 60px 10px calc(74px + env(safe-area-inset-bottom)); overflow: auto; }
  #page-workbench, #page-asinops, #page-selection, #page-adanalysis, #page-labeltool, #page-labels, #page-kwresearch, #page-aiassistant {
    margin: -10px; height: calc(100dvh - 114px - env(safe-area-inset-bottom)); overflow: hidden;
  }
  #page-workbench iframe, #page-asinops iframe, #page-selection iframe, #page-adanalysis iframe, #page-labeltool iframe, #page-labels iframe, #page-kwresearch iframe { height: 100%; }

  .page h2 { margin: 0 0 12px; font-size: 17px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .stat-card { padding: 12px; }
  .stat-card .num { font-size: 22px; }
  .toolbar { gap: 8px; margin-bottom: 10px; }
  .toolbar > input, .toolbar > select { width: 100%; min-height: 44px; }
  .btn, .btn-plain { min-height: 42px; padding: 9px 12px; }

  /* AI 助手：会话栏横向排列，保留更多聊天高度 */
  .chat-wrap { height: 100%; flex-direction: column; }
  .chat-sidebar {
    width: 100%; height: auto; flex: none; padding: 7px 8px;
    border: 0; border-bottom: 1px solid var(--line); display: grid;
    grid-template-columns: auto auto minmax(0, 1fr); gap: 6px;
  }
  .chat-sidebar #chat-new, .chat-sidebar #chat-skills { width: auto; white-space: nowrap; }
  .conv-list { min-width: 0; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; }
  .conv-item { min-width: 120px; max-width: 180px; min-height: 42px; padding: 7px 9px; background: var(--gray-soft); }
  .conv-del { display: flex; align-items: center; justify-content: center; }
  .chat-main { min-height: 0; }
  .chat-head { min-height: 48px; padding: 8px 10px; gap: 8px; }
  .chat-head h2 { min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-head-actions { gap: 5px; }
  .chat-head-actions .btn { min-height: 36px; padding: 7px 8px; font-size: 12px; }
  .chat-list { padding: 12px 10px; gap: 9px; }
  .msg { max-width: 88%; padding: 9px 11px; font-size: 14px; }
  .chat-inputbar { gap: 6px; padding: 8px 8px calc(9px + env(safe-area-inset-bottom)); align-items: flex-end; }
  .chat-inputbar textarea { min-height: 44px; max-height: 110px; font-size: 16px; }
  #chat-file-btn, #chat-send { min-height: 44px; padding: 9px 11px; }

  /* 用户列表改为卡片，避免手机横向拖表格 */
  #page-users { overflow: visible; }
  #page-users table, #page-users tbody, #page-users tr, #page-users td { display: block; width: 100%; }
  #page-users table { border: 0; background: transparent; box-shadow: none; }
  #page-users thead { display: none; }
  #page-users tr { margin-bottom: 10px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
  #page-users td { min-height: 38px; padding: 8px 0 8px 94px; border-bottom: 1px solid #f0f4f2; position: relative; white-space: normal; word-break: break-word; }
  #page-users td:last-child { border: 0; padding-left: 0; display: flex; gap: 6px; flex-wrap: wrap; }
  #page-users td::before { position: absolute; left: 0; top: 9px; width: 86px; color: var(--ink3); font-size: 12px; font-weight: 600; }
  #page-users td:nth-child(1)::before { content: "ID"; }
  #page-users td:nth-child(2)::before { content: "用户名"; }
  #page-users td:nth-child(3)::before { content: "显示名"; }
  #page-users td:nth-child(4)::before { content: "角色"; }
  #page-users td:nth-child(5)::before { content: "状态"; }
  #page-users td:nth-child(6)::before { content: "领星店铺"; }
  #page-users td:nth-child(7)::before { content: "创建时间"; }
  #page-users td:nth-child(8)::before { content: none; }
  .role-inline, .lx-multi-btn { min-height: 38px; max-width: 100%; }
  .lx-multi-panel { left: 8px !important; right: 8px; top: 58px !important; width: auto; max-height: calc(100dvh - 140px); }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    width: 100%; max-width: none; max-height: 88dvh; padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
  .modal-actions { position: sticky; bottom: 0; padding-top: 10px; background: var(--card); }
  .modal-actions button { flex: 1; min-height: 44px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .skill-toolbar, .skill-actions { flex-wrap: wrap; }
  .skill-item { align-items: flex-start; flex-direction: column; }
  .skill-actions { width: 100%; }
  .skill-actions .btn { flex: 1; }
}

@media (max-width: 380px) {
  .sidebar nav a .nav-txt, .sidebar.collapsed nav a .nav-txt { font-size: 9px; }
  .user-box { padding-inline: 8px; }
  .link-btn { padding-inline: 7px; font-size: 12px; }
  .stats { grid-template-columns: 1fr; }
  .chat-sidebar { grid-template-columns: 1fr 1fr; }
  .conv-list { grid-column: 1 / -1; }
}
