/* ============================================================
   讲师门户前端 · 左侧边栏布局
   白灰蓝主色，微软雅黑字体，扁平简洁风格
   ============================================================ */
:root {
  --primary: #2563EB;
  --primary-soft: #EFF6FF;
  --accent: #F59E0B;
  --bg: #F9FAFB;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --muted: #6B7280;
  --sidebar-bg: #FFFFFF;
  --sidebar-text: #4B5563;
  --sidebar-active-bg: #EFF6FF;
  --sidebar-active-text: #2563EB;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.12);
  --green: #16A34A;
  --red: #DC2626;
}

[data-theme="dark"] {
  --primary: #3B82F6;
  --primary-soft: #1E293B;
  --bg: #0F172A;
  --card: #1E293B;
  --border: #334155;
  --text: #E2E8F0;
  --muted: #94A3B8;
  --sidebar-bg: #1E293B;
  --sidebar-text: #94A3B8;
  --sidebar-active-bg: #2563EB;
  --sidebar-active-text: #FFFFFF;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 左侧边栏 ============ */
.portal-sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 30;
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  padding: 28px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  max-width: 160px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
  cursor: pointer;
  margin: 2px 8px;
  border-radius: 6px;
}
.sidebar-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-user-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout {
  display: block;
  width: 100%;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: center;
  font-family: inherit;
}
.sidebar-logout:hover { background: var(--bg); color: var(--text); }

/* ============ 右侧内容区 ============ */
.portal-content {
  margin-left: 220px;
  flex: 1;
  min-width: 0;           /* flex 子项截断必须 */
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;      /* 防止内容撑宽页面 */
}

/* ============ 登录页（全屏，无边栏） ============ */
.portal-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 40px 60px;
  background: url('/login-bg.jpg') no-repeat center center / 100% 100%;
}
.portal-login-card {
  width: 380px;
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 36px 32px;
  margin-right: 60px;
}
.portal-login-card h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.portal-login-card .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}
.portal-login-card .field { margin-bottom: 18px; }
.portal-login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
/* 通用 input/select 样式（与合作伙伴端 org.html 一致） */
.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--card);
  color: var(--text);
  height: 36px;
  box-sizing: border-box;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
select.input { cursor: pointer; }
input[type="date"].input { cursor: pointer; }
.portal-login-card .input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.portal-login-card .input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.portal-login-card .btn-primary {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.portal-login-card .btn-primary:hover { background: #1D4ED8; }
.portal-login-card .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.portal-login-card .err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.portal-login-card .switch-link { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ============ 内容区通用 ============ */
.portal-main {
  padding: 28px 36px;
  min-width: 0;
  overflow-x: hidden;   /* 防止子内容撑宽 */
}
.portal-main h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
/* 模块标题行：图标+标题垂直居中，下方加分割线，内容在分割线以下 */
.portal-main .module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.portal-main h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* ============ 卡片 ============ */
.portal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.portal-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

/* 课程包/课程卡片 hover + 选中效果（浅蓝背景） */
.pack-card:hover,
.lesson-card:hover {
  background: var(--primary-soft) !important;
  border-color: rgba(37,99,235,.35);
}
.pack-card.pack-selected,
.lesson-card.lesson-selected {
  background: rgba(37,99,235,.08) !important;
  border-color: var(--primary) !important;
}

/* ============ Tab 切换 ============ */
.portal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.portal-tab {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.portal-tab:hover { color: var(--text); }
.portal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ============ 表单 ============ */
.portal-form .field { margin-bottom: 12px; }
.portal-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.portal-form .input, .portal-form .select, .portal-form .textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.portal-form .input:focus, .portal-form .select:focus, .portal-form .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.portal-form .textarea { resize: vertical; min-height: 64px; }
.portal-form .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 只读字段（账号信息展示） */
.readonly-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  min-height: 40px;
  display: flex;
  align-items: center;
}

/* ============ 按钮规范（统一尺寸/字号/无阴影） ============
   尺寸体系：
   - 常规按钮 .btn-primary / .btn-outline：高 40px，字号 14px，圆角 var(--radius)（圆角矩形）
   - 小按钮 .btn-sm：高 30px，字号 13px，圆角 6px
   - 字段行内按钮 .field-action-btn：与字段框等高 40px，圆角与字段框一致
   字体统一微软雅黑，字号随按钮大小适配（40px→14px，30px→13px）
   【一致性铁律（用户 2026-08-28 确认）】按钮与输入框/只读字段框并排同行时，
   必须与字段框等高（用 .field-action-btn），不用 .btn-sm；
   所有页面按钮保持尺寸一致，视觉对齐优先。
   所有按钮统一无 box-shadow，圆角 var(--radius)，字体微软雅黑。 */
.btn-primary,
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
  box-shadow: none !important;
}
.btn-primary {
  border: none;
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: #1D4ED8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
.btn-outline:hover {
  background: rgba(37, 99, 235, .06);   /* 低透明度蓝色 */
  border-color: rgba(37, 99, 235, .35);
  color: var(--primary);
}
.btn-outline:active {
  background: rgba(37, 99, 235, .12);
  border-color: rgba(37, 99, 235, .5);
}
.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 6px;
}
.btn-sm.btn-primary, .btn-sm.btn-outline { height: 30px; padding: 0 12px; font-size: 13px; line-height: 1; }
.btn-danger { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

/* 字段行内动作按钮：与 readonly-field / input 同行等高对齐（40px），圆角与字段框一致，宽度适配内容 */
.field-action-btn {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  border-radius: var(--radius);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  padding: 0 14px;
}

/* v214 换绑弹窗顶部 Tab（无分割线风格，激活态主色下划线） */
.cp-tab {
  flex: 1;
  padding: 10px 0 12px;
  font-size: 14px;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.cp-tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

/* 课程卡片内按钮悬浮：纯蓝底白字（区别于通用 btn-outline 的淡蓝 hover） */
.lesson-card .btn-outline:hover,
.lesson-card .btn-outline:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 单行截断工具类 */
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图标按钮（返回等） */
.btn-icon:hover { background: rgba(37, 99, 235, .06); color: var(--primary); border-color: rgba(37, 99, 235, .35); }

/* ============ 标签 ============ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
}
.tag-green { background: #D1FAE5; color: #065F46; }
.tag-yellow { background: #FEF3C7; color: #92400E; }
.tag-gray { background: #F3F4F6; color: #6B7280; }
.tag-blue { background: #DBEAFE; color: #1D4ED8; }
.tag-red { background: #FEE2E2; color: #991B1B; }

/* ============ 表格 ============ */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.portal-table th {
  text-align: left;
  padding: 0 12px;
  height: 40px;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.portal-table td {
  padding: 0 12px;
  height: 44px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  background: var(--card);
  font-size: 13px;
  line-height: 1.4;
}
.portal-table tbody tr:hover td { background: var(--primary-soft); }
.portal-table tbody tr.selected td { background: var(--primary-soft); }
/* 操作列：默认隐藏，行 hover/选中时显示 */
.portal-table .cell-actions { visibility: hidden; }
.portal-table tbody tr:hover .cell-actions,
.portal-table tbody tr.selected .cell-actions { visibility: visible; }
/* v0.9.0 列表统一样式规范：数据单行显示、超长省略号（title 悬浮看全文）、小屏自适应 */
.portal-table { table-layout: auto; }
.portal-table th, .portal-table td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.portal-table td[title] { cursor: help; }
/* 表格外层滚动容器：小屏放不下时横向滚动，不换行 */
.portal-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.portal-table-scroll::-webkit-scrollbar { height: 6px; }
.portal-table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
/* 小屏隐藏次要列 */
@media (max-width: 900px) {
  .portal-table .col-audience, .portal-table .col-partner { display: none; }
}
@media (max-width: 600px) {
  .portal-table .col-pack { display: none; }
}

/* ============ 空状态 ============ */
.portal-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ============ 弹窗 ============ */
.portal-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.portal-modal-mask.open { display: flex; }
.portal-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: calc(100vw - 32px);
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: portalPop .18s ease;
}
@keyframes portalPop {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.portal-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.portal-modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.portal-modal-body { padding: 14px 18px; flex: 1; min-height: 0; overflow-y: auto; }
.portal-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
}

/* 弹窗关闭按钮 */
.x-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
  padding: 0;
}
.x-btn:hover { background: var(--bg); color: var(--text); }

/* ============ Toast ============ */
.portal-toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.portal-toast {
  padding: 11px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  min-width: 220px;
  animation: portalSlideIn .2s ease;
}
.portal-toast.err { border-left-color: var(--red); }
@keyframes portalSlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============ 统计卡片 ============ */
.portal-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.portal-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.portal-stat .label { font-size: 12px; color: var(--muted); }
.portal-stat .value { font-size: 22px; font-weight: 700; color: var(--primary); margin-top: 4px; }

/* ============ 合作伙伴列表行 ============ */
.portal-table-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.portal-table-row:last-child { border-bottom: none; }

/* ============ 移动端顶栏与抽屉遮罩（仅移动端显示） ============ */
.m-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  z-index: 110;
}
.m-menu-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text);
  cursor: pointer; flex-shrink: 0;
  padding: 0;
}
.m-menu-btn:active { background: var(--primary-soft); color: var(--primary); }
.m-topbar .m-title {
  flex: 1;
  font-size: 16px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 119;
}

/* ============ 响应式（移动端自适应 v0.6.4） ============ */
@media (max-width: 768px) {
  /* --- 顶栏与抽屉 --- */
  .m-topbar { display: flex; }
  body.portal-login-page .m-topbar { display: none; }
  body.m-drawer-open .m-mask { display: block; }

  /* 侧边栏变抽屉：默认收在屏幕外，加 body.m-drawer-open 滑出 */
  .portal-sidebar {
    display: flex !important;
    transform: translateX(-102%);
    transition: transform .25s ease;
    width: 250px;
    min-width: 250px;
    z-index: 130;
    box-shadow: none;
  }
  body.m-drawer-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(15,23,42,.25);
  }
  /* navigate() 写入的内联样式在移动端失效 */
  .portal-content[style] { margin-left: 0 !important; }

  /* --- 内容区 --- */
  .portal-content { margin-left: 0; padding-top: 52px; }
  .portal-main { padding: 16px 14px 28px; }
  .portal-main h2 { font-size: 17px; }

  /* --- 登录页：手机端用浅蓝渐变替代背景图（电脑端保留原图） --- */
  .portal-login {
    justify-content: center;
    padding: 20px 16px;
    background: linear-gradient(165deg, #93C5FD 0%, #BFDBFE 40%, #E0F2FE 100%);
  }
  .portal-login-card {
    margin-right: 0;
    width: 100%;
    max-width: 380px;
    padding: 28px 22px;
  }

  /* --- 表格：触屏无 hover，操作列常显 --- */
  .portal-table .cell-actions { visibility: visible; }
  .portal-table th, .portal-table td { max-width: 240px; }
  .portal-table td { height: 48px; }

  /* --- Tab 横向滑动 --- */
  .portal-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* v0.6.5：tab 均分宽度自动压缩，3 个 tab 一行放下不用横滑；超长 tab 名换行 */
  .portal-tab {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 6px;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
    word-break: break-all;
  }

  /* --- 课程包详情课程卡片：标题一行、按钮换行到下一行（v0.6.5） --- */
  .lesson-card { flex-wrap: wrap !important; }
  .lesson-card > div:first-child { flex: 1 1 100% !important; }
  /* 标题行内的元信息/主题标签允许换行 */
  .lesson-card > div:first-child > div { flex-wrap: wrap; }
  /* 按钮行换到标题下方，按钮平铺铺满整行，触屏更好按 */
  .lesson-card > div:last-child {
    width: 100% !important;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px dashed var(--border);
  }
  .lesson-card > div:last-child .btn-sm { flex: 1 1 0; height: 34px; }

  /* --- 更多信息：客户经理三卡片由横滑改为自动换行（v0.6.5） --- */
  .portal-main [style*="flex-wrap:nowrap"] {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
  }
  .portal-main [style*="flex-wrap:nowrap"] > * {
    flex: 1 1 160px !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  /* --- 弹窗：底部按钮加大触屏热区 --- */
  .portal-modal-mask { padding: 12px; align-items: flex-end; }
  .portal-modal { max-height: calc(100vh - 70px); }
  .portal-modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .portal-modal-foot .btn-primary,
  .portal-modal-foot .btn-outline { flex: 1; }
  .portal-modal-body { padding: 12px 14px; }

  /* --- Toast：移到顶部栏下方居中 --- */
  .portal-toast-wrap {
    top: 60px; left: 12px; right: 12px;
    align-items: stretch;
  }
  .portal-toast { min-width: 0; }

  /* --- 内联双列/三列表单网格在小屏降为两列以内 --- */
  .portal-main [style*="grid-template-columns"],
  .portal-modal-body [style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* --- 统计卡片 --- */
  .portal-stat { padding: 14px 16px; }
  .portal-stat .value { font-size: 20px; }

  /* --- 分页/工具行允许换行 --- */
  .portal-card { padding: 14px; }

  /* --- 客服悬浮窗不超出屏幕 --- */
  #kefu-float { width: calc(100vw - 32px) !important; max-width: 280px; }
}

/* 极小屏（<400px）：表单网格进一步降为单列 */
@media (max-width: 400px) {
  .portal-main [style*="grid-template-columns"],
  .portal-modal-body [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}
