/* ============================================================
   kk-adaptive.css  v1  —  自适应布局 / 紧凑间距 / 备注加长
   目标: 任何屏幕宽度都不需要手动调缩放，功能按钮全部可见可点
   规则全部加 !important，覆盖 Tailwind 固定值
   ============================================================ */

/* ---------- 1. 取消固定最小宽度，改为自然收缩 ---------- */
@media (max-width: 1499px) {
  html, body { overflow-x: hidden !important; }
  main div.flex.gap-3.flex-1:has([role=tablist]) {
    min-width: 0 !important;
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  main div.flex.gap-3.flex-1:has([role=tablist]) > div:first-child,
  main div.flex.gap-3.flex-1:has([role=tablist]) > div:last-child {
    flex: 1 1 420px !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  main h2 div.flex { flex-wrap: wrap !important; }
}

/* ---------- 2. 文字自适应：窄屏自动降 1~2 级，不再需要手动缩放 ---------- */
@media (max-width: 1400px) {
  main .text-base { font-size: 14px !important; }
  main .text-sm    { font-size: 12.5px !important; line-height: 1.35 !important; }
  main .text-xs    { font-size: 11.5px !important; line-height: 1.3 !important; }
  main h2, main h3 { font-size: 15px !important; }
}
@media (max-width: 1150px) {
  main .text-base { font-size: 13px !important; }
  main .text-sm    { font-size: 12px !important; }
  main .text-xs    { font-size: 11px !important; }
  main .text-lg    { font-size: 14px !important; }
  main .text-xl    { font-size: 15px !important; }
}
/* 所有文本默认可换行，不截断 */
main button, main td, main th, main label, main span { min-width: 0; }
main td, main th { white-space: normal !important; word-break: break-word; }

/* ---------- 3. 间距收紧（等比压缩，内容更多可见） ---------- */
main .gap-4 { gap: 0.5rem !important; }
main .gap-3 { gap: 0.4rem !important; }
main .gap-2 { gap: 0.3rem !important; }
main .gap-1\.5 { gap: 0.225rem !important; }
main .space-y-3 > * + * { margin-top: 0.4rem !important; }
main .space-y-2 > * + * { margin-top: 0.3rem !important; }
main .space-y-1\.5 > * + * { margin-top: 0.225rem !important; }
main .p-4 { padding: 0.6rem !important; }
main .p-3 { padding: 0.45rem !important; }
main .px-4 { padding-left: 0.6rem !important; padding-right: 0.6rem !important; }
main .py-3 { padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
main .py-2 { padding-top: 0.3rem !important; padding-bottom: 0.3rem !important; }
main .py-1\.5 { padding-top: 0.2rem !important; padding-bottom: 0.2rem !important; }
main .py-6 { padding-top: 0.6rem !important; padding-bottom: 0.6rem !important; }
main .mb-3 { margin-bottom: 0.4rem !important; }
main .mt-3 { margin-top: 0.4rem !important; }
main .mb-2 { margin-bottom: 0.3rem !important; }
main .mt-2 { margin-top: 0.3rem !important; }

/* 按钮不再被固定高度裁掉文字：只给最小高度，内容多时自动增高 */
main button { height: auto !important; min-height: 26px; line-height: 1.25 !important; }
main button.h-9 { min-height: 32px !important; }
main [class*="grid-cols-5"] { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)) !important; }
main [class*="grid-cols-4"] { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)) !important; }
main [class*="grid-cols-3"] { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important; }

/* ---------- 4. 表格 / 列表：内部横向滚动，不再撑破页面 ---------- */
main div.flex-1.overflow-auto.min-h-0 { overflow: auto !important; }
main table { width: 100% !important; table-layout: auto; }
main table tbody tr { height: auto !important; min-height: 30px; }
main table td, main table th { padding: 5px 6px !important; }

/* ---------- 5. 屏幕面板：保持设备真实比例（不再强制 9:19 拉伸）---------- */
main div.flex.gap-3.flex-1:has([role=tablist]) > div:first-child .items-start .rounded-2xl:not(.shadow-2xl) {
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: auto !important;
  height: auto !important;
}
main div.flex.gap-3.flex-1:has([role=tablist]) > div:first-child .items-start canvas,
main div.flex.gap-3.flex-1:has([role=tablist]) > div:first-child .items-start img,
main div.flex.gap-3.flex-1:has([role=tablist]) > div:first-child .items-start video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block;
}

/* ---------- 6. 备注：加长成多行输入区 ---------- */
main input[placeholder="输入备注..."],
main input[placeholder*="备注"] {
  min-height: 26px;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
}
/* JS 生成的加长备注区（kk-adaptive.js 注入） */
.kk-note-box {
  display: block;
  width: 100% !important;
  min-height: 84px;
  max-height: 220px;
  resize: vertical;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 6px 8px;
  outline: none;
  font-family: inherit;
}
.kk-note-box:focus { border-color: #2f81f7; }
.kk-note-wrap { width: 100%; min-width: 0; }

/* ---------- 7. 金融应用置顶标记 ---------- */
tr.kk-finance-pinned > td:first-child { box-shadow: inset 3px 0 0 #f0a020; }
.kk-fin-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 15px;
  border-radius: 3px;
  background: rgba(240, 160, 32, .14);
  color: #f0a020;
  border: 1px solid rgba(240, 160, 32, .35);
  vertical-align: middle;
}

/* ---------- 8. 一键：整页自适应缩放（JS 写 zoom 变量用）---------- */
main.kk-autofit { transform-origin: top left; }


/* ============================================================
   kk-adaptive.css  v2  —  整体字号降档 / 竖排按钮优化 / 分页紧凑
   v1: 自适应宽度 + 间距收紧
   v2: 全宽度生效的字号缩放 + 侧边栏竖排按钮重排 + 分页 UI 缩小
   ============================================================ */

/* ---------- 9. 全宽度字号降档（不再只在窄屏生效）---------- */
main .text-sm    { font-size: 12.5px !important; line-height: 1.4 !important; }
main .text-xs    { font-size: 11px   !important; line-height: 1.35 !important; }
main .text-base  { font-size: 13px   !important; line-height: 1.45 !important; }
main .text-lg    { font-size: 14px   !important; line-height: 1.4 !important; }
main .text-xl    { font-size: 15.5px !important; line-height: 1.35 !important; }
main .text-2xl   { font-size: 17px   !important; line-height: 1.3 !important; }
main .text-3xl   { font-size: 20px   !important; line-height: 1.2 !important; }
main h1 { font-size: 17px   !important; }
main h2 { font-size: 14.5px !important; }
main h3 { font-size: 13px   !important; line-height: 1.35 !important; }
main label { font-size: 12px !important; }
main input, main select, main textarea { font-size: 12.5px !important; }

/* 顶部栏整体下压 */
header, [role="banner"] { height: 40px !important; min-height: 40px !important; }
header *, [role="banner"] * { font-size: 12.5px; }

/* ---------- 10. 侧边栏：竖排按钮重排（19 项一屏尽量全露）---------- */
:root, [class*="sidebar-wrapper"] { --sidebar-width: 172px !important; }

/* 侧边栏滚动区：细滚动条 + 更密的项间距 */
div[class*="text-sidebar-foreground"] [class*="overflow-auto"] {
  gap: 1px !important;
  padding: 4px 6px 8px !important;
  scrollbar-width: thin;
}
div[class*="text-sidebar-foreground"] [class*="overflow-auto"]::-webkit-scrollbar { width: 4px; }
div[class*="text-sidebar-foreground"] [class*="overflow-auto"]::-webkit-scrollbar-thumb {
  background: #30363d; border-radius: 2px;
}

/* 分组标题：15px/33px高 -> 10.5px/18px高 */
div[class*="text-sidebar-foreground"] [class*="text-[15px]"][class*="font-bold"] {
  font-size: 10.5px !important;
  line-height: 1 !important;
  height: 18px !important;
  min-height: 18px !important;
  padding: 0 8px !important;
  margin: 5px 0 1px !important;
  display: flex !important;
  align-items: center !important;
  letter-spacing: .04em;
  opacity: .78;
}

/* 竖排按钮本体：36px高/15px字 -> 27px高/12.5px字 */
div[class*="text-sidebar-foreground"] a,
div[class*="text-sidebar-foreground"] button {
  height: 27px !important;
  min-height: 27px !important;
  max-height: 27px !important;
  font-size: 12.5px !important;
  line-height: 1 !important;
  padding: 0 8px !important;
  border-radius: 5px !important;
  gap: 7px !important;
  justify-content: flex-start !important;
  text-align: left !important;
}
/* 图标缩小，文字不挤压 */
div[class*="text-sidebar-foreground"] a svg,
div[class*="text-sidebar-foreground"] button svg {
  width: 14px !important; height: 14px !important;
  min-width: 14px !important; flex-shrink: 0 !important;
}
div[class*="text-sidebar-foreground"] a span,
div[class*="text-sidebar-foreground"] button span {
  font-size: 12.5px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* 侧边栏头（Logo/标题）/ 尾部用户区同步收紧 */
div[class*="text-sidebar-foreground"] > div > div:first-child { padding: 6px 8px !important; }
div[class*="text-sidebar-foreground"] img { max-height: 22px !important; }

/* ---------- 11. 分页控件紧凑（JS 打标 .kk-pager）---------- */
.kk-pager, .kk-pager * { font-size: 11px !important; line-height: 1.25 !important; }
.kk-pager button, .kk-pager [role="button"] {
  height: 22px !important; min-height: 22px !important;
  padding: 0 7px !important; border-radius: 4px !important;
  font-size: 11px !important;
}
.kk-pager { gap: 4px !important; padding: 2px 0 !important; }

/* 兜底：表格下方出现的页码条（上一页/下一页/共N条） */
main .kk-pager-row { gap: 4px !important; font-size: 11px !important; }
main .kk-pager-row > * { font-size: 11px !important; }

/* ---------- 12. 卡片 / 表格 / 按钮再收一档 ---------- */
main .p-5 { padding: 0.7rem !important; }
main .p-6 { padding: 0.8rem !important; }
main .py-6 { padding-top: 0.7rem !important; padding-bottom: 0.7rem !important; }
main .space-y-4 > * + * { margin-top: 0.55rem !important; }
main .space-y-6 > * + * { margin-top: 0.7rem !important; }
main table th { font-size: 11px !important; padding: 5px 7px !important; height: 28px !important; }
main table td { font-size: 12px !important; padding: 5px 7px !important; height: 30px !important; }
main button { font-size: 12px !important; }
main [role="tablist"] button { font-size: 12px !important; min-height: 26px !important; padding: 2px 9px !important; }
main [role="tab"] { font-size: 12px !important; }

/* Badge 类小标签 */
main .rounded-full.px-2\.5, main .rounded-full.px-2 { font-size: 10px !important; height: 18px !important; line-height: 18px !important; }

/* ---------- 13. 窄屏再降一档（不影响功能，只缩字号）---------- */
@media (max-width: 1200px) {
  main .text-sm   { font-size: 12px !important; }
  main .text-base { font-size: 12.5px !important; }
  main .text-3xl  { font-size: 18.5px !important; }
  :root, [class*="sidebar-wrapper"] { --sidebar-width: 162px !important; }
  div[class*="text-sidebar-foreground"] a,
  div[class*="text-sidebar-foreground"] button { height: 26px !important; min-height: 26px !important; max-height: 26px !important; font-size: 12px !important; }
}
@media (max-width: 1024px) {
  :root, [class*="sidebar-wrapper"] { --sidebar-width: 152px !important; }
  div[class*="text-sidebar-foreground"] a,
  div[class*="text-sidebar-foreground"] button { height: 25px !important; min-height: 25px !important; max-height: 25px !important; font-size: 11.5px !important; }
  div[class*="text-sidebar-foreground"] a svg,
  div[class*="text-sidebar-foreground"] button svg { width: 13px !important; height: 13px !important; }
}

/* ---------- 14. 绝不出现横向滚动条 ---------- */
html, body { overflow-x: hidden !important; max-width: 100vw !important; }
main { overflow-x: hidden !important; min-width: 0 !important; }
main table { max-width: 100% !important; }


/* ============================================================
   v2.1 修补：竖排按钮不折行 / 宽度回调 / 底栏单行
   ============================================================ */
:root, [class*="sidebar-wrapper"] { --sidebar-width: 184px !important; }

/* 侧边栏内一律不折行，超长省略，保证按钮高度稳定在 27px */
div[class*="text-sidebar-foreground"] a,
div[class*="text-sidebar-foreground"] button,
div[class*="text-sidebar-foreground"] a *,
div[class*="text-sidebar-foreground"] button * {
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  flex-wrap: nowrap !important;
  line-height: 1 !important;
}
div[class*="text-sidebar-foreground"] a > *,
div[class*="text-sidebar-foreground"] button > * { min-width: 0 !important; }

/* 侧边栏整体（含底栏、Logo 行）也不折行 */
div[class*="text-sidebar-foreground"] { white-space: nowrap !important; }
div[class*="text-sidebar-foreground"] [class*="border-t"] { white-space: nowrap !important; }
/* 底栏状态行：单行、12px */
div[class*="text-sidebar-foreground"] [class*="border-t"] * { font-size: 11.5px !important; white-space: nowrap !important; }
/* Logo 标题 */
div[class*="text-sidebar-foreground"] img { flex-shrink: 0 !important; }

@media (max-width: 1200px) {
  :root, [class*="sidebar-wrapper"] { --sidebar-width: 176px !important; }
}
@media (max-width: 1024px) {
  :root, [class*="sidebar-wrapper"] { --sidebar-width: 168px !important; }
}


/* ============================================================
 v2.2 分页条整体压紧(每页行数/页码/箭头都缩)
 ============================================================ */
.kk-pager { margin-top: 4px !important; gap: 4px !important; row-gap: 2px !important; }
.kk-pager button,
.kk-pager [role="button"],
.kk-pager a {
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 6px !important;
  font-size: 11px !important;
  line-height: 22px !important;
  border-radius: 5px !important;
}
.kk-pager select,
.kk-pager input {
  height: 24px !important;
  min-height: 24px !important;
  padding: 0 5px !important;
  font-size: 11px !important;
  line-height: 22px !important;
  border-radius: 5px !important;
}
.kk-pager span, .kk-pager div, .kk-pager label, .kk-pager p {
  font-size: 11px !important;
  line-height: 1.25 !important;
}
.kk-pager svg { width: 12px !important; height: 12px !important; }

/* 搜索框:禁止被拉伸成多行块 */
main input[placeholder*="搜索"], main input[placeholder*="查找"] {
  height: 26px !important;
  min-height: 26px !important;
  max-height: 26px !important;
  line-height: 20px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ============================================================
 v2.3 修:内容少的页面卡片被压扁导致工具条/表格被裁
 (flex-basis:0 在 auto 高度父容器里塌成 0,overflow:hidden 把内容切掉)
 ============================================================ */
main .p-4.flex.flex-col.overflow-hidden > .flex-1,
main [class*="max-h-[calc(100vh"] > .flex-1 {
  flex: 1 1 auto !important;
  min-height: fit-content !important;
}

/* ============================================================
 v2.4 修:APK构建页 三台手机图标预览溢出,压住右侧「自动构建」卡
 ============================================================ */
main div[class*="w-[340px]"][class*="h-[740px]"] {
  zoom: 0.56 !important;
  flex: 0 0 auto !important;
}
@media (max-width: 1520px) {
  main div[class*="w-[340px]"][class*="h-[740px]"] { zoom: 0.50 !important; }
}
@media (max-width: 1300px) {
  main div[class*="w-[340px]"][class*="h-[740px]"] { zoom: 0.44 !important; }
}
/* 兜底:预览行绝不允许溢出到右侧列 */
main div:has(> div[class*="w-[340px]"]) { max-width: 100% !important; overflow: hidden !important; }

/* ============================================================
 v2.5 侧边栏再压一档:1440x900 下 19 项全部可见(不再需要滚动)
 ============================================================ */
div[class*="text-sidebar-foreground"] [class*="space-y"] { gap: 1px !important; }
div[class*="text-sidebar-foreground"] a,
div[class*="text-sidebar-foreground"] button {
  height: 25px !important;
  min-height: 25px !important;
  max-height: 25px !important;
  margin: 0 !important;
}
div[class*="text-sidebar-foreground"] > div > div:first-child {
  padding: 4px 8px 2px !important;
  font-size: 11px !important;
  line-height: 1 !important;
}
div[class*="text-sidebar-foreground"] [class*="text-muted-foreground"] {
  font-size: 10.5px !important;
}

/* v2.6 干掉侧边栏项之间残留的 space-y 外边距(才能 19 项全显示) */
div[class*="text-sidebar-foreground"] [class*="space-y"] > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
div[class*="text-sidebar-foreground"] ul,
div[class*="text-sidebar-foreground"] li { margin: 0 !important; }
div[class*="text-sidebar-foreground"] > div > div:first-child { margin: 2px 0 0 !important; }

/* v2.7 侧边栏最后压一档:22px 项高 + 分组标题/底栏收紧 => 19 项全显示 */
div[class*="text-sidebar-foreground"] a,
div[class*="text-sidebar-foreground"] button {
  height: 22px !important;
  min-height: 22px !important;
  max-height: 22px !important;
  font-size: 12px !important;
}
div[class*="text-sidebar-foreground"] a svg,
div[class*="text-sidebar-foreground"] button svg { width: 13px !important; height: 13px !important; }
div[class*="text-sidebar-foreground"] > div > div:first-child {
  padding: 3px 8px 1px !important;
  font-size: 10.5px !important;
  margin-top: 3px !important;
}
div[class*="text-sidebar-foreground"] [class*="border-t"] {
  padding: 3px 8px !important;
  margin-top: 2px !important;
}
div[class*="text-sidebar-foreground"] [class*="border-t"] * {
  font-size: 10px !important;
  line-height: 1.15 !important;
}
