:root {
  --bg: #070b16;
  --bg-soft: #0d1424;
  --card: #111a2e;
  --card-2: #16203a;
  --line: #1f2c48;
  --text: #e8eefc;
  --text-dim: #8ea0c4;
  --text-faint: #5f7099;
  --accent: #3ea6ff;
  --accent-2: #46d9a8;
  --warn: #ffb545;
  --danger: #ff5f6d;
  --purple: #9d7bff;
  --radius: 12px;
  --gap: 14px;
}

* {
  box-sizing: border-box;
}

/* hidden 属性必须压过组件自己的 display —— .panel 用 display:flex 布局，
   而作者样式表天生优先于浏览器默认样式表里的 [hidden]{display:none}，
   不加这条，配置面板加了 hidden 也关不掉。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 15% -10%, #14213c 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 30, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.15;
  text-align: center;
  color: #08111f;
  flex: none;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

select,
input[type='text'],
input[type='password'],
input[type='number'] {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 13px;
  font-family: inherit;
  max-width: 220px;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(255, 95, 109, 0.35);
}

.menu {
  position: relative;
}

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  min-width: 148px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 30;
}

.menu-list a {
  display: block;
  padding: 7px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
}

.menu-list a:hover {
  background: var(--card-2);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.dot.live {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(70, 217, 168, 0.16);
}

.dot.down {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 95, 109, 0.16);
}

.clock {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---------------- 栅格 ---------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gap);
  padding: var(--gap) 20px 28px;
  align-items: start;
}

.ops-strip {
  margin: 18px 0 28px;
  padding: 18px;
  background: var(--card, #121a2a);
  border: 1px solid var(--line, #26344f);
  border-radius: 8px;
}

.shot-delete {
  position: absolute;
  right: 4px;
  top: 4px;
  border: 0;
  padding: 3px 6px;
  color: #fff;
  background: rgba(180, 44, 58, .9);
  border-radius: 4px;
  cursor: pointer;
}

.ops-strip .kpis {
  grid-template-columns: repeat(6, minmax(110px, 1fr));
}

@media (max-width: 900px) {
  .ops-strip .kpis { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

.card {
  /*
    占宽由 render() 按区块配置写成三个行内变量：
      --span     宽屏（>1100px）占几格 —— 就是配置面板里选的那个值
      --span-md  中屏（≤1100px）夹取后的格数
      --span-sm  窄屏（≤720px）夹取后的格数
    这里的 4 / 6 / 12 只是万一没写变量时的兜底。

    曾经是 `span 4` 加两条 `grid-column: span 6/12 !important` 的媒体查询。
    !important 连行内样式都压得过，于是配成整宽的区块（凭证照片、库存明细）
    在笔记本屏上一律被切成半屏，配置里选的 12 根本没机会生效。
    改成变量以后，媒体查询只决定「用哪一档」，配置值始终说得上话。
  */
  --span: 4;
  --span-md: 6;
  --span-sm: 12;
  grid-column: span var(--span);
  background: linear-gradient(180deg, var(--card) 0%, rgba(13, 20, 36, 0.92) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  min-width: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
}

.card-head .meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------------- 区块拖拽排序 ---------------- */

/*
  只有把手能起手拖动，整块卡片不是 draggable。
  卡片里有表格、可点的指标、能放大的照片；把整块设成可拖，选一段文字、
  点一个数字都会变成「开始拖动」，那些交互全废了。
*/
.card-grip {
  display: inline-block;
  margin-right: 8px;
  /* 按住这里拖，所以给足点击面积；负的 margin 让它不撑高标题行 */
  padding: 0 4px;
  margin-left: -4px;
  color: var(--text-faint);
  cursor: grab;
  /* 把手本身不该被选中：拖动时双击选中会先高亮一段文字 */
  user-select: none;
  font-size: 13px;
  line-height: 1;
}

.card-grip:hover {
  color: var(--accent);
}

.card-grip:active {
  cursor: grabbing;
}

/* 正在被拖的那块：留一个虚框占位，看得出它原来在哪 */
.card.dragging {
  opacity: 0.45;
  border-style: dashed;
  border-color: var(--accent);
}

.empty {
  color: var(--text-faint);
  font-size: 13px;
  padding: 18px 0;
  text-align: center;
}

/* ---------------- 指标卡 ---------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
}

/* 可下钻的卡片。没登记下钻的卡片外观一点不变 —— 全都做成可点的样子、
   点下去却没有详情，比不可点更糟。右上角那个箭头是唯一的静态提示。 */
.kpi-drill {
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s, background 0.12s;
}

.kpi-drill::after {
  content: '›';
  position: absolute;
  top: 8px;
  right: 11px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-faint);
}

.kpi-drill:hover {
  border-color: var(--accent);
  background: #1a2544;
}

.kpi-drill:hover::after {
  color: var(--accent);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-value {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
}

.tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(62, 166, 255, 0.16);
  color: var(--accent);
  flex: none;
}

/* ---------------- 图表 ---------------- */

.chart-wrap {
  position: relative;
}

canvas {
  display: block;
  width: 100%;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
}

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(6, 11, 22, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  z-index: 10;
}

.chart-tip .tip-day {
  color: var(--text-dim);
  margin-bottom: 2px;
}

/* ---------------- 列表 / 表格 ---------------- */

.rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.row-bar {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 9px;
}

.row-bar .idx {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row-bar .body {
  min-width: 0;
}

.row-bar .name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-bar .track {
  height: 5px;
  border-radius: 3px;
  background: var(--card-2);
  margin-top: 5px;
  overflow: hidden;
}

.row-bar .fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
}

.row-bar .val {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}

.row-bar .sub {
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(31, 44, 72, 0.7);
  white-space: nowrap;
}

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11.5px;
  position: sticky;
  top: 0;
  background: var(--card);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:hover {
  background: rgba(62, 166, 255, 0.06);
}

/* 单元格里的第二行小字：业务日期下面挂真正的记账时刻。 */
.cell-sub {
  color: var(--text-faint);
  font-size: 10.5px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

td.wrap {
  white-space: normal;
  min-width: 220px;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
}

.pill {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 20px;
  border: 1px solid transparent;
}

.pill.critical {
  color: var(--danger);
  background: rgba(255, 95, 109, 0.13);
  border-color: rgba(255, 95, 109, 0.3);
}

.pill.warning {
  color: var(--warn);
  background: rgba(255, 181, 69, 0.12);
  border-color: rgba(255, 181, 69, 0.28);
}

.pill.info {
  color: var(--accent);
  background: rgba(62, 166, 255, 0.12);
  border-color: rgba(62, 166, 255, 0.28);
}

.pill.a {
  color: var(--accent-2);
  background: rgba(70, 217, 168, 0.12);
}

.pill.b {
  color: var(--warn);
  background: rgba(255, 181, 69, 0.1);
}

.pill.c {
  color: var(--text-faint);
  background: rgba(95, 112, 153, 0.14);
}

.pos {
  color: var(--accent-2);
}

.neg {
  color: var(--danger);
}

.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.alert {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--card-2);
  border-left: 3px solid var(--line);
}

.alert.critical {
  border-left-color: var(--danger);
}

.alert.warning {
  border-left-color: var(--warn);
}

.alert.info {
  border-left-color: var(--accent);
}

/* pill 是 .alert 这个 grid 的直接子项，grid 子项默认 align-self: stretch ——
   它会被拉到整行高（商品名 + 说明两行，约 40px），border-radius: 20px 落在
   40px 高的盒子上就成了一个鸭蛋。start 让它回到一行高，并跟商品名对齐。
   定宽居中是另一件事：标签有 3~6 个字（「已断货」到「低于再订货点」），
   auto 列宽会让右边的文字列一行一个起点，竖着看很花。 */
.alert .pill {
  align-self: start;
  min-width: 80px;
  text-align: center;
  white-space: nowrap;
}

.alert .who {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.alert .msg {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.counts {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
}

/* ---------------- 指标下钻明细 ---------------- */

.drill-sub {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.drill-group {
  margin-top: 16px;
}

.drill-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.drill-warehouse {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.drill-code {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.drill-sum {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 健康分 ---------------- */

.health {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.gauge {
  position: relative;
  width: 132px;
  flex: none;
}

.gauge-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.gauge-score {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gauge-grade {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.breakdown {
  flex: 1;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bd-row {
  font-size: 12px;
}

.bd-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.bd-top .label {
  color: var(--text-dim);
}

.bd-top .penalty {
  font-variant-numeric: tabular-nums;
}

.bd-track {
  height: 4px;
  background: var(--card-2);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.bd-fill {
  height: 100%;
  background: var(--danger);
  border-radius: 2px;
}

.bd-detail {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ---------------- 配置面板 ---------------- */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.5);
}

.panel-head,
.panel-foot {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-foot {
  border-bottom: none;
  border-top: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.panel-field {
  display: block;
  margin-bottom: 12px;
}

.panel-field > span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.panel-field input {
  width: 100%;
  max-width: none;
}

.panel-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 10px;
}

.panel-section-head h3 {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.checkbox {
  font-size: 12px;
  color: var(--text-dim);
}

.cfg-blocks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cfg-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
}

.cfg-block-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.cfg-block-head .type {
  font-size: 11px;
  color: var(--accent);
  background: rgba(62, 166, 255, 0.12);
  padding: 2px 7px;
  border-radius: 5px;
  flex: none;
}

.cfg-block-head input[type='text'] {
  flex: 1;
  min-width: 110px;
  max-width: none;
}

.cfg-block-head .icon {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.cfg-block-head .icon:hover {
  color: var(--text);
  border-color: var(--accent);
}

.cfg-conf {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.cfg-conf > label > span {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.chip.on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(62, 166, 255, 0.12);
}

.chip-group-name {
  font-size: 10.5px;
  color: var(--text-faint);
  width: 100%;
  margin-top: 3px;
}

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.toast.bad {
  border-color: rgba(255, 95, 109, 0.5);
  color: #ffd9dc;
}

/* ---------------- 身份与登录 ---------------- */

.me-name {
  color: var(--text-dim);
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 覆盖层的 z-index 必须压过页面上所有浮层（配置面板 40、toast 60），
   否则登录框会被盖在它们底下，而且底下那些控件在没登录时一个都不该点得到。 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 11, 22, 0.92);
  backdrop-filter: blur(3px);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.login-card h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.login-hint {
  margin: -6px 0 4px;
  font-size: 12px;
  color: var(--text-faint);
}

/* 卡片自己用 gap 控间距，把 .panel-field 的 margin 收掉免得两套叠加。 */
.login-card .panel-field {
  margin-bottom: 0;
}

/* 口令框是 type=password，不在 :124 那条通用规则里，必须单独给。 */
.login-card input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 9px 11px;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-error {
  margin: 0;
  font-size: 12.5px;
  color: #ffd9dc;
  background: rgba(255, 95, 109, 0.12);
  border: 1px solid rgba(255, 95, 109, 0.45);
  border-radius: 8px;
  padding: 7px 10px;
  line-height: 1.5;
}

.login-card .btn.primary {
  margin-top: 4px;
  padding: 10px;
  font-size: 14px;
}

/* ---------------- 商户对比（平台超管） ---------------- */

.tenant-table tbody tr {
  cursor: pointer;
}

.tenant-table td.idx {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  width: 34px;
}

.tenant-table td.name {
  min-width: 190px;
}

.tenant-table td.name .bar {
  height: 3px;
  margin-top: 5px;
  border-radius: 3px;
  background: rgba(31, 44, 72, 0.9);
  overflow: hidden;
}

.tenant-table td.name .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------------- 商户管理面板（平台超管） ---------------- */

.tn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.panel-note {
  margin: 2px 0 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-dim);
}

.panel-note strong {
  color: var(--warn);
  font-weight: 600;
}

/* 面板底部那条结果提示。.tn-result 是它的原名（只有商户面板用），改口令面板也要同一个样子。 */
.tn-result,
.panel-result {
  margin: 11px 0 0;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.65;
  background: rgba(70, 217, 168, 0.1);
  border: 1px solid rgba(70, 217, 168, 0.32);
  color: var(--accent-2);
}

/* 失败必须是红的：「当前口令不正确」印在绿框里会被读成「改成功了」。 */
.panel-result.bad {
  background: rgba(255, 95, 109, 0.13);
  border-color: rgba(255, 95, 109, 0.3);
  color: var(--danger);
}

.tn-count {
  font-size: 12px;
  color: var(--text-faint);
}

.tn-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.tn-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--card);
}

.tn-item-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tn-item-head .tn-name {
  flex: 1;
  min-width: 0;
  max-width: none;
}

.tn-code {
  font-size: 12px;
  color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}

.tn-state {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.tn-state.active {
  background: rgba(70, 217, 168, 0.14);
  color: var(--accent-2);
}

.tn-state.suspended {
  background: rgba(255, 95, 109, 0.14);
  color: var(--danger);
}

.tn-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 9px;
}

.tn-meta {
  min-width: 0;
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-item-foot .inline {
  margin-left: auto;
}

/*
  套餐价格。一行 = 一档：名称与说明占满上面一行，季付 / 年付两个输入框和
  「恢复默认」并排在下面。照 .tn-item 的卡片观感，免得同一个面板里两种风格。
*/
.pp-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 11px;
}

.pp-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--card);
}

.pp-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 7px;
}

/*
  输入框那一行单独一层。不用 .pp-row 自己当栅格 + grid-column 把标题拉满 ——
  整份样式表里 grid-column 只许用来表达「卡片占几格」（见 --span 那套变量），
  多一条别的用法就得在测试里开个例外。
*/
.pp-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 0 12px;
}

/* 默认价那句话是次要信息，长了就截掉，别把输入框挤下去。 */
.pp-meta {
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pp-row .panel-field {
  margin-bottom: 0;
}

.pp-row .pp-reset {
  margin-bottom: 1px;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1100px) {
  .card {
    grid-column: span var(--span-md);
  }

  .tn-grid {
    grid-template-columns: 1fr;
  }

  /* 窄屏上两个输入框并排会各剩几十像素，价钱看不全。落成一列。 */
  .pp-fields {
    grid-template-columns: 1fr;
  }

  .pp-row .pp-reset {
    justify-self: start;
    margin-top: 4px;
  }
}

@media (max-width: 720px) {
  .grid {
    padding: var(--gap) 12px 24px;
  }
  .card {
    grid-column: span var(--span-sm);
  }
  .status {
    border-left: none;
    padding-left: 0;
  }
  .topbar {
    padding: 12px;
  }
}

/* ---------------- 单据凭证照片 ---------------- */

.vouchers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/*
  收起来的那些单。靠 [hidden]{display:none!important} 关掉（那条兜底规则在文件开头，
  有用例守着）—— 所以这里的 display:flex 不会把它压开。
*/
.voucher-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voucher-more {
  /* 靠左、不撑满：它是一个次要入口，铺成整宽会比它收起来的内容还抢眼。 */
  align-self: flex-start;
  color: var(--text-faint);
}

.voucher-more:hover {
  color: var(--text);
}

.voucher-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
}

.voucher-meta {
  /* 单号那列定宽：右边的缩略图排数才不会随往来单位名字长短一行一变。
     min-width:0 是给下面 ellipsis 用的，flex 子项默认不肯收缩到内容以下。 */
  flex: 0 0 210px;
  min-width: 0;
}

.voucher-meta .name {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voucher-meta .sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voucher-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.voucher-shot {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 92px;
  cursor: zoom-in;
}

.voucher-thumb {
  width: 92px;
  height: 92px;
  /* cover 会裁掉边角，但凭证是要看清内容的，宁可留黑边也别裁掉盖章那一角。 */
  object-fit: contain;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.voucher-shot:hover .voucher-thumb {
  border-color: var(--accent);
}

.shot-stamp {
  /*
    「经办人 + 录入时间」在大屏这一侧再叠一遍。

    照片像素里那份水印是手机在上传前烧的（见小程序 utils/watermark.js），老版本基础库、
    带 EXIF 旋转标记的照片会烧不上；这一层用的是服务端自己记的 uploaded_by / created_at，
    永远有值、客户端也改不了，所以这两个事实一定看得见。

    92px 宽写不下一行，拆两行 + ellipsis；完整值在 title 和大图说明里。
  */
  font-size: 10px;
  line-height: 1.35;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.shot-stamp span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-overlay {
  /*
    故意**不**改 z-index：沿用 .overlay 的 90 就够了 —— 明细面板是 .panel(40)、
    toast 是 60，大图已经压在它们上面。而 #photo-overlay 写在 #login-overlay 之前，
    同为 90 时后者靠 DOM 顺序压在上面：401 掉回登录时，登录框不会被一张照片挡住。
  */
  cursor: zoom-out;
}

.photo-frame {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  max-height: 100%;
}

.photo-frame img {
  /* 减掉 figcaption 那行的高度，否则竖构图的照片会把说明挤出屏幕外。 */
  max-width: 100%;
  max-height: calc(100vh - 90px);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #000;
}

.photo-frame figcaption {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .voucher-row {
    /* 窄屏一行放不下「定宽单号 + 一排缩略图」，改成上下两段。 */
    flex-direction: column;
    align-items: stretch;
  }
  .voucher-meta {
    flex: none;
  }
}

/* ---------------- 订阅与配额 ---------------- */

/* 顶栏那颗药丸。默认是安静的（accent 描边），只在快到期/已到期时才变色 ——
   一个天天发红的提示等于没有提示。 */
.sub-pill {
  border: 1px solid rgba(62, 166, 255, 0.45);
  background: rgba(62, 166, 255, 0.1);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 11px;
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sub-pill:hover {
  background: rgba(62, 166, 255, 0.2);
}

.sub-pill.warn {
  border-color: rgba(255, 181, 69, 0.5);
  background: rgba(255, 181, 69, 0.12);
  color: var(--warn);
}

.sub-pill.warn:hover {
  background: rgba(255, 181, 69, 0.22);
}

.sub-pill.bad {
  border-color: rgba(255, 95, 109, 0.55);
  background: rgba(255, 95, 109, 0.14);
  color: var(--danger);
}

.sub-pill.bad:hover {
  background: rgba(255, 95, 109, 0.24);
}

.sub-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.sub-fact {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  padding: 10px 12px;
}

.sub-fact span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.sub-fact b {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

.sub-fact .bad,
.sub-result .bad {
  color: var(--danger);
}

.sub-h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}

.sub-result {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
  line-height: 1.7;
}

.sub-ok {
  color: var(--accent-2);
}

.sub-result code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}

/* 转账信息是运维在 PAY_TRANSFER_INFO 里写的多行文本，原样换行显示。 */
.sub-transfer {
  margin: 6px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* 微信扫码。二维码是服务端画好的 SVG，这里只负责给它一块**纯白**底 ——
   大屏是深色的，把码直接摆上去有些扫码器对不出来。 */
.sub-qr-box {
  margin: 10px 0 4px;
}

.sub-qr {
  width: max-content;
  padding: 9px;
  border-radius: 10px;
  background: #fff;
  line-height: 0;
}

.sub-qr svg {
  display: block;
  width: 172px;
  height: 172px;
}

.cfg-quota {
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid rgba(62, 166, 255, 0.3);
  border-radius: 8px;
  background: rgba(62, 166, 255, 0.07);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-dim);
}

.cfg-quota .bad {
  color: var(--danger);
}

/* 置灰的类型在多数浏览器里已经够暗了，这里只是把颜色统一到设计里。 */
#cfg-add-type option:disabled {
  color: var(--text-faint);
}

/* 被折叠区块的说明卡。用虚线边框跟真正出数的卡片区分开 ——
   它是一条说明，不是一块数据。 */
.card.locked-note {
  border-style: dashed;
  border-color: rgba(255, 181, 69, 0.4);
  background: rgba(255, 181, 69, 0.05);
}

.card.locked-note .card-head h2 {
  color: var(--warn);
}

.locked-body {
  padding: 4px 2px 2px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-dim);
}

.locked-body p {
  margin: 0 0 6px;
}

.locked-body b {
  color: var(--text);
}
