/* 云启运营控制台 —— 少量本地样式（Tabler 之外的补充；无任何外链） */
:root {
  --yq-brand: #4d6bfe;
}

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--yq-brand);
  box-shadow: 0 0 0 4px rgba(77, 107, 254, 0.18);
}

.nav-link-icon svg {
  width: 20px;
  height: 20px;
  vertical-align: -3px;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
  background: color-mix(in srgb, var(--tblr-body-bg) 88%, transparent);
}

/* 14 天趋势条 */
.trend {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 8px;
}
.trend .bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.trend .bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #6b8cff 0%, #3b5bdb 100%);
  transition: filter 0.15s ease;
}
.trend .bar-wrap:hover .bar { filter: brightness(1.25); }
.trend .tick {
  margin-top: 6px;
  font-size: 10px;
  color: var(--tblr-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.trend .count {
  font-size: 10px;
  text-align: center;
  color: var(--tblr-secondary);
  margin-bottom: 2px;
}

/* 平台分布条（类名加 yq- 前缀，避免与 Tabler/主题冲突） */
.plat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.plat .name {
  width: 10em;
  flex: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.plat .yq-track {
  flex: 1;
  height: 8px;
  background: var(--tblr-border-color);
  border-radius: 4px;
  overflow: hidden;
}
.plat .yq-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 4px;
  background: var(--yq-brand);
}
.plat .num {
  width: 3.5em;
  text-align: right;
  font-size: 12px;
  color: var(--tblr-secondary);
  flex: none;
}

/* 订单表：窄屏密度与可读性 */
.table-orders td, .table-orders th { white-space: nowrap; }
.table-orders .col-customer { max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.num { font-variant-numeric: tabular-nums; }
.masked { letter-spacing: 0.02em; }

/* 时间线 */
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline:before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--tblr-border-color);
}
.timeline li { position: relative; padding: 0 0 14px 26px; }
.timeline li:before {
  content: "";
  position: absolute;
  left: 2px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--tblr-body-bg);
  background: var(--yq-brand);
}
.timeline .t-time { font-size: 12px; color: var(--tblr-secondary); }
.timeline .t-title { font-weight: 600; }
.timeline .t-detail { font-size: 13px; color: var(--tblr-secondary); white-space: pre-wrap; }

/* 命令面板（⌘K） */
/* 可访问性：跳转链接 / 键盘焦点 */
.trend a.bar-wrap { color: inherit; text-decoration: none; }
.trend a.bar-wrap:hover .bar { filter: brightness(1.08); }
.trend a.bar-wrap:focus-visible { outline: 2px solid #206bc4; outline-offset: 2px; }

.yq-row-check { margin-right: .4rem; vertical-align: middle; }
.yq-check-all { margin-right: .4rem; }
.yq-ctx-menu {
  position: fixed;
  z-index: 1100;
  min-width: 200px;
  padding: .3rem;
  background: var(--tblr-bg-surface, #fff);
  border: 1px solid var(--tblr-border-color, #dce1e7);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  display: flex;
  flex-direction: column;
}
.yq-ctx-menu button,
.yq-ctx-menu a {
  display: block;
  padding: .4rem .55rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font-size: .85rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.yq-ctx-menu button:hover,
.yq-ctx-menu a:hover { background: var(--tblr-bg-surface-secondary, #f6f8fb); }

/* 工作流运行详情：日志片段 */
.wf-log {
  max-height: 46vh;
  overflow: auto;
  background: var(--tblr-bg-surface-secondary, #f6f8fb);
  color: #182433;
  border: 1px solid var(--tblr-border-color, #dce1e7);
  border-radius: 8px;
  padding: .6rem .75rem;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}
.wf-log .ln { color: var(--tblr-secondary, #667382); user-select: none; margin-right: .6rem; }
.wf-log .hit { background: rgba(245, 159, 0, .18); display: block; }
[data-bs-theme="dark"] .wf-log { color: #e6e7e9; }

.wf-grid { display: flex; gap: 3px; flex-wrap: nowrap; }
.wf-cell { width: 14px; height: 20px; border-radius: 3px; display: inline-block; }
.wf-ok { background: #2fb344; }
.wf-fail { background: #d63939; }
.wf-unknown { background: #aab2bd; }

.yq-anchors { position: relative; }
.card[id] { scroll-margin-top: 84px; }
.yq-lt-filter { min-width: 120px; }
.yq-lt-count { white-space: nowrap; }
.wf-errors-scroll { max-height: 460px; overflow: auto; }

/* 移动端：次要操作收进「更多」 */
.yq-more { display: none; position: relative; }
.yq-more > summary { list-style: none; }
.yq-more > summary::-webkit-details-marker { display: none; }
.yq-more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 1100;
  min-width: 130px; padding: .3rem;
  background: var(--tblr-bg-surface, #fff);
  border: 1px solid var(--tblr-border-color, #dce1e7);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
}
.yq-more-menu > a, .yq-more-menu > button {
  padding: .4rem .55rem; border: 0; border-radius: 6px; background: transparent;
  color: inherit; text-align: left; text-decoration: none; font-size: .85rem;
}
.yq-more-menu > a:hover, .yq-more-menu > button:hover { background: var(--tblr-bg-surface-secondary, #f6f8fb); }
@media (max-width: 576px) {
  #theme-toggle, #density-toggle, .yq-refresh, .yq-help, .yq-logout { display: none !important; }
  .yq-more { display: block; }
}

/* 页面一句话提示（背后是 hints.PAGE_HINTS） */
.page-hint {
  max-width: 62em;
  padding-left: .55rem;
  border-left: 3px solid var(--tblr-primary, #206bc4);
}

/* 列表能力包：视图/列/CSV/打印（无构建，见 list_tools.js） */
.yq-list-tools {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
}
.yq-lt-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 1030;
  min-width: 220px;
  max-height: 320px;
  overflow: auto;
  padding: .4rem;
  background: var(--tblr-bg-surface, #fff);
  border: 1px solid var(--tblr-border-color, #dce1e7);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
.yq-lt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .25rem .35rem;
  font-size: .85rem;
}
.yq-lt-row:hover { background: var(--tblr-bg-surface-secondary, #f6f8fb); }
@media print { .yq-list-tools { display: none !important; } }

.yq-skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 2000;
  background: var(--tblr-bg-surface, #fff);
  color: var(--tblr-body-color, #182433);
  padding: .5rem 1rem;
  border: 1px solid var(--tblr-border-color, #dce1e7);
  border-radius: 6px;
}
.yq-skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid #206bc4; outline-offset: 2px; }

.cmdk { position: fixed; inset: 0; z-index: 1050; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.cmdk-panel {
  position: relative;
  margin: 12vh auto 0;
  width: min(640px, 92vw);
  background: var(--tblr-body-bg);
  border: 1px solid var(--tblr-border-color);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  padding: 12px;
}
.cmdk-panel .form-control { font-size: 16px; }
.cmdk-list { max-height: 48vh; overflow: auto; margin-top: 8px; }
.cmdk-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}
.cmdk-item:hover, .cmdk-item.active { background: rgba(77, 107, 254, 0.18); }
.cmdk-kind { color: var(--tblr-secondary); font-size: 12px; flex: none; }
.cmdk-empty { padding: 14px 10px; color: var(--tblr-secondary); }
.cmdk-hint { margin-top: 8px; font-size: 12px; color: var(--tblr-secondary); text-align: right; }

/* 表格密度（density，借鉴 shadcn/TanStack 的 compact） */
body.dense .table > :not(caption) > * > * { padding: 0.35rem 0.5rem; }
body.dense .table { font-size: 0.875rem; }
body.dense .card-body { padding: 0.75rem; }

/* 主从抽屉（借鉴 Sentry/Grafana：列表点行 → 右侧详情，保留完整页深链） */
.yq-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; transition: opacity .18s ease; z-index: 1030;
}
.yq-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.yq-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(540px, 94vw);
  background: var(--tblr-body-bg); border-left: 1px solid var(--tblr-border-color);
  box-shadow: -16px 0 40px rgba(0, 0, 0, .35);
  transform: translateX(100%); transition: transform .2s ease; z-index: 1035;
  display: flex; flex-direction: column;
}
.yq-drawer.open { transform: none; }
.yq-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--tblr-border-color); }
.yq-panel-body { padding: 12px 16px; overflow: auto; }
.yq-timeline-compact li { margin-bottom: 8px; }

/* 列显示控制（自绘 panel，避开 Tabler/Bootstrap dropdown 的键盘处理器） */
.yq-cols { position: relative; }
.yq-cols > summary { list-style: none; }
.yq-cols > summary::-webkit-details-marker { display: none; }
.yq-cols-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 1000;
  min-width: 180px; background: var(--tblr-body-bg);
  border: 1px solid var(--tblr-border-color); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
.yq-cols-panel .form-check { margin-bottom: .25rem; }

/* 移动端：表格 → 卡片（统一 .table-cards；保留旧 .table-orders 兼容） */
@media (max-width: 768px) {
  .table-orders thead, .table-cards thead { display: none; }
  .table-orders, .table-orders tbody, .table-orders tr, .table-orders td,
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-orders tr, .table-cards tr {
    border: 1px solid var(--tblr-border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 6px 10px;
  }
  .table-orders td, .table-cards td { border: 0; white-space: normal; padding: 3px 0; }
  .table-orders td[data-label]:before, .table-cards td[data-label]:before {
    content: attr(data-label) "：";
    color: var(--tblr-secondary);
    font-size: 12px;
  }
  .trend { height: 90px; }
  .plat .name { width: 7em; }
  body { padding-bottom: 60px; }
  .page-header { position: static; }
  /* 手机顶栏：按钮换行、去掉 ⌘K 提示字符，避免挤压 */
  .page-header .col-auto { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  .page-header .btn { padding: .2rem .5rem; font-size: 13px; }
  #cmdk-open kbd { display: none; }
  .card-header { flex-wrap: wrap; gap: 6px; }
  .card-header .card-actions { flex-wrap: wrap; }
  .card-header .card-title { font-size: 1.1rem; }
}

/* 移动端底部导航 */
@media (max-width: 768px) {
  /* 底部导航是 fixed，必须给内容留出安全区，否则最后一行会被压住 */
  .page-body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
  .trend .tick { font-size: 9px; }
  /* 14 根柱在 390px 宽下标签必叠：每 3 根只显示 1 个日期（其余保留 tooltip） */
  .trend .bar-wrap .tick { visibility: hidden; }
  .trend .bar-wrap:nth-child(3n + 1) .tick { visibility: visible; }
  .table-cards tr { break-inside: avoid; }
}

@media (max-width: 576px) {
  /* 窄屏头部：标题独占一行，动作条换行到下一行，避免「总览」被挤成竖排 */
  .page-header .row { flex-wrap: wrap; }
  .page-header .page-pretitle { display: none; }
  .page-header .page-title { font-size: 1.45rem; white-space: nowrap; }
  .page-header .col-auto.ms-auto {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    row-gap: .35rem;
  }
}

.yq-bottom-nav { display: none; }
@media (max-width: 768px) {
  .yq-bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020;
    background: var(--tblr-body-bg); border-top: 1px solid var(--tblr-border-color);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .yq-bottom-nav a {
    flex: 1; text-align: center; font-size: 12px; padding: 4px 0;
    color: var(--tblr-secondary); text-decoration: none;
  }
  .yq-bottom-nav a.active { color: var(--tblr-primary); font-weight: 600; }
}

/* 打印：仓库清单 / 对账单（隐藏导航与按钮，白底，表格可读） */
@media print {
  .navbar, .navbar-toggler, .yq-bottom-nav, .yq-drawer, .yq-drawer-backdrop, .cmdk,
  .card-actions .btn, .btn, .form-select, .pagination, .yq-cols { display: none !important; }
  body { background: #fff !important; padding: 0 !important; }
  .page, .page-wrapper, .page-body, .container-xl { display: block !important; margin: 0 !important; padding: 0 !important; }
  .card { border: 0 !important; box-shadow: none !important; }
  .card-header, .card-body, .table-responsive { padding: 0 !important; }
  .table { font-size: 11px; }
  .table th, .table td { border-color: #bbb !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .badge { border: 1px solid #999; }
}

/* 订单/单据详情：统一文档头（借鉴 Odoo/ERPNext 文档表单） */
.yq-doc-hero .card-header { align-items: flex-start; }
.yq-doc-hero .yq-doc-title { font-size: 1.35rem; letter-spacing: .01em; }
.yq-doc-hero .yq-doc-sub { color: var(--tblr-secondary); font-size: 13px; }
.yq-stages { display: flex; flex-wrap: wrap; gap: 6px; }
.yq-stage {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 1.6;
  border: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary); background: var(--tblr-bg-surface);
}
.yq-stage:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tblr-border-color); }
.yq-stage.is-done { color: var(--tblr-green); border-color: color-mix(in srgb, var(--tblr-green) 35%, transparent); background: color-mix(in srgb, var(--tblr-green) 8%, transparent); }
.yq-stage.is-done:before { background: var(--tblr-green); }
.yq-stage.is-current { color: var(--yq-brand); border-color: color-mix(in srgb, var(--yq-brand) 40%, transparent); background: color-mix(in srgb, var(--yq-brand) 8%, transparent); }
.yq-stage.is-current:before { background: var(--yq-brand); }
.yq-section-nav {
  position: sticky; top: 4.1rem; z-index: 5;
  padding: 6px 0;
  background: color-mix(in srgb, var(--tblr-body-bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--tblr-border-color);
}
.yq-doc-section { scroll-margin-top: 5.5rem; }
.yq-doc-facts .text-secondary { font-size: 12px; }
.yq-doc-facts .num { font-size: 15px; }
