/* ============ 集团资金总览 ============ */

/* KPI strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(205, 169, 91, 0.22);
  border-radius: 4px;
  pointer-events: none;
}

.kpi-card.risk { border-color: #E5C6C1; background: linear-gradient(180deg, #FFF9F8, #fff); }

.kpi-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 5px;
  background: var(--parchment);
  border: 1px solid var(--line);
  color: var(--brass-600);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon svg { width: 17px; height: 17px; }
.kpi-card.risk .kpi-icon { color: var(--red-500); background: var(--red-bg); border-color: #EAC5C0; }

.kpi-label { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.kpi-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.25;
  white-space: nowrap;
}

.kpi-card.risk .kpi-value { color: var(--red-600); }
.kpi-value .kpi-unit { font-family: var(--sans); font-size: 11px; font-weight: 400; color: var(--ink-3); margin: 0 3px 0 2px; }
.kpi-delta { font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ============ Middle row ============ */
.mid-row {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr) 292px;
  gap: 10px;
  align-items: stretch;
}

/* Entity tree */
.panel-tree { display: flex; flex-direction: column; }
.tree-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.tree-search { width: 100%; }

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
}

.tree-node:hover { background: var(--green-50); }
.tree-node.selected { background: var(--green-100); color: var(--green-900); font-weight: 600; }
.tree-node { min-width: 0; }
.tree-node .tree-toggle { width: 12px; font-size: 9px; color: var(--ink-3); text-align: center; flex-shrink: 0; }
.tree-node .node-dot { flex-shrink: 0; }
.tree-node > span:nth-child(3) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tree-node .tree-count-badge { margin-left: auto; font-size: 10.5px; color: var(--ink-3); font-family: var(--mono); flex-shrink: 0; }
.tree-node .node-dot { width: 6px; height: 6px; border-radius: 2px; background: var(--brass-400); flex-shrink: 0; }
.tree-children { margin-left: 14px; border-left: 1px dotted var(--line-strong); padding-left: 4px; }

.tree-sep {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-strong);
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.segment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-2);
}

.segment-item:hover { background: var(--green-50); }
.segment-item.selected { background: var(--green-100); color: var(--green-900); font-weight: 600; }
.segment-item .num { font-size: 11px; color: var(--ink-3); }

.tree-foot { display: flex; gap: 6px; margin-top: 4px; }

.tree-foot-btn {
  flex: 1;
  text-align: center;
  font-size: 11.5px;
  padding: 4px 0;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink-3);
  cursor: pointer;
}

.tree-foot-btn.active { background: var(--green-800); border-color: var(--green-800); color: #F5EFDD; }
.tree-count { font-size: 11px; color: var(--ink-3); text-align: center; }

/* Pipeline */
.panel-pipeline { display: flex; flex-direction: column; min-width: 0; }

.pipe-mode {
  font-size: 11.5px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink-3);
  cursor: pointer;
}

.pipe-mode.active { background: var(--green-800); border-color: var(--green-800); color: #F5EFDD; }

.pipe-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-bottom: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.pipe-meta-item b { font-size: 15px; color: var(--green-900); margin: 0 3px; }

.pipe-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
}

.legend-pipe { display: inline-block; width: 18px; border-radius: 2px; background: var(--green-700); }
.legend-pipe.w1 { height: 2px; }
.legend-pipe.w2 { height: 4px; }
.legend-pipe.w3 { height: 7px; }

.legend-gauge {
  display: inline-block;
  width: 12px;
  height: 7px;
  border-radius: 7px 7px 0 0;
  border: 2px solid var(--red-500);
  border-bottom: none;
}

.pipe-table { margin: 8px 12px 12px; }
.pipe-canvas table { width: calc(100% - 24px); }

.pipe-canvas { flex: 1; min-height: 380px; position: relative; }
.pipe-canvas svg { width: 100%; height: 100%; display: block; }

.pipe-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
}

.pipe-foot-opts { display: flex; gap: 12px; }
.pipe-foot-opts label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* SVG pipeline internals */
.pipe-edge { fill: none; stroke: var(--green-700); opacity: 0.75; transition: opacity 0.15s, stroke 0.15s; }
.pipe-edge.dim { opacity: 0.15; }
.pipe-edge.hl { stroke: var(--brass-500); opacity: 1; }

.pipe-flow {
  fill: none;
  stroke: rgba(242, 222, 170, 0.9);
  stroke-dasharray: 3 14;
  stroke-linecap: round;
  animation: pipeFlow 1.6s linear infinite;
  pointer-events: none;
}

@keyframes pipeFlow { to { stroke-dashoffset: -17; } }

.seg-node rect { fill: #FFFFFF; stroke: var(--line-strong); rx: 5; }
.seg-node.selected rect, .seg-node:hover rect { stroke: var(--brass-500); stroke-width: 1.6; }
.seg-node { cursor: pointer; }
.seg-icon { fill: var(--parchment); stroke: var(--brass-500); }
.seg-name { font-size: 11.5px; font-weight: 600; fill: var(--ink); }
.seg-balance { font-family: var(--mono); font-size: 12.5px; font-weight: 700; fill: var(--green-800); }
.seg-accounts { font-size: 9.5px; fill: var(--ink-3); }

.hub-outer { fill: var(--green-800); stroke: var(--brass-400); stroke-width: 2.5; }
.hub-inner { fill: none; stroke: rgba(242, 222, 170, 0.4); stroke-dasharray: 2 4; }
.hub-name { fill: #F5EFDD; font-size: 13px; font-weight: 700; }
.hub-sub { fill: rgba(245, 239, 221, 0.75); font-size: 9.5px; }
.hub-amount { fill: var(--brass-100); font-family: var(--mono); font-size: 15px; font-weight: 700; }

.flow-label { font-family: var(--mono); font-size: 9.5px; fill: var(--ink-2); }
.flow-label-bg { fill: var(--paper); opacity: 0.9; }

.bank-node rect { fill: #FFFFFF; stroke: var(--line-strong); }
.bank-name { font-size: 10px; fill: var(--ink-2); }
.bank-balance { font-family: var(--mono); font-size: 11.5px; font-weight: 700; fill: var(--green-800); }

.anomaly-card rect.frame { fill: #FFF9F8; stroke: #E5C6C1; }
.anomaly-card.mid rect.frame { fill: #FDF9EF; stroke: #EBD9AE; }
.anomaly-title { font-size: 10px; font-weight: 600; fill: var(--ink); }
.anomaly-desc { font-size: 9px; fill: var(--ink-3); }
.gauge-arc-bg { fill: none; stroke: #EAE4D2; stroke-width: 4; stroke-linecap: round; }
.gauge-arc { fill: none; stroke-width: 4; stroke-linecap: round; }
.gauge-needle { stroke: var(--ink); stroke-width: 1.4; transform-origin: center; animation: needleTwitch 2.4s ease-in-out infinite; }

@keyframes needleTwitch {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(3deg); }
  60% { transform: rotate(-2.4deg); }
}

/* Briefing */
.panel-briefing { display: flex; flex-direction: column; }
.ai-badge {
  font-size: 10.5px;
  color: var(--brass-600);
  border: 1px solid var(--brass-200);
  background: var(--amber-bg);
  border-radius: 3px;
  padding: 1px 6px;
}

.briefing-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.brief-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--green-900);
  padding-bottom: 5px;
  border-bottom: 1px dashed var(--line);
}

.brief-section-title .tag { margin-left: auto; }

.brief-item {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
}

.brief-item .dot { margin-top: 5px; flex-shrink: 0; }
.brief-trend { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.brief-trend .delta { font-weight: 600; }

.brief-advice {
  background: var(--parchment);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
}

.brief-advice .conf { display: block; font-size: 10.5px; color: var(--brass-600); margin-top: 2px; }
.brief-foot { font-size: 10.5px; color: var(--ink-3); line-height: 1.5; border-top: 1px dashed var(--line); padding-top: 7px; }

/* ============ Bottom row ============ */
.bottom-row {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 10px;
  align-items: stretch;
}

.head-sub { font-size: 11px; font-weight: 400; color: var(--ink-3); margin-left: 4px; }

.mini-tabs { display: flex; gap: 2px; font-size: 11.5px; }

.mini-tab {
  padding: 2px 8px;
  border-radius: 3px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}

.mini-tab:hover { color: var(--green-800); }
.mini-tab.active { background: var(--red-bg); color: var(--red-600); font-weight: 600; }

.panel-alerts { display: flex; flex-direction: column; }
.panel-alerts .table-wrap { flex: 1; }

.panel-alerts-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}

/* Mini guarantee graph */
.mini-circle-tags { display: flex; gap: 6px; margin-bottom: 4px; }
#miniGuarantee { min-height: 240px; }
#miniGuarantee svg { width: 100%; display: block; }

.mini-circle-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.mini-circle-legend > span { display: flex; align-items: center; gap: 5px; }
.legend-line { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--green-700); }
.legend-line.dashed { border-top-style: dashed; border-top-color: var(--red-500); }

.mg-node circle { fill: #fff; stroke: var(--green-700); stroke-width: 1.4; }
.mg-node.risk circle { stroke: var(--red-500); }
.mg-node text { font-size: 9.5px; fill: var(--ink-2); }
.mg-node .mg-amount { font-family: var(--mono); font-size: 9px; fill: var(--green-800); font-weight: 700; }
.mg-edge { stroke: var(--green-700); stroke-width: 1.3; fill: none; }
.mg-edge.risk { stroke: var(--red-500); stroke-dasharray: 4 3; }
.mg-halo { fill: rgba(192, 57, 43, 0.06); stroke: rgba(192, 57, 43, 0.35); stroke-dasharray: 3 3; }
.mg-flag { font-size: 9.5px; font-weight: 700; fill: var(--red-600); }

/* Reconciliation */
.panel-recon { display: flex; flex-direction: column; }
.panel-recon .card-body { flex: 1; display: flex; flex-direction: column; gap: 9px; }

.recon-tabs { display: flex; gap: 6px; }

.recon-tab {
  font-size: 11.5px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-block;
}

.recon-tab.active { background: var(--green-800); border-color: var(--green-800); color: #F5EFDD; }

.recon-grid {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
}

.recon-row { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr; }
.recon-row > div { padding: 6px 9px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.recon-row:last-child > div { border-bottom: none; }
.recon-row.head > div { background: var(--parchment); color: var(--ink-3); font-weight: 600; border-bottom: 1px double var(--line-strong); }
.recon-row .num { font-weight: 600; }
.recon-row .diff { text-align: right; font-family: var(--mono); font-weight: 700; color: var(--red-500); }
.recon-row.main > div { background: #FDFCF7; }
.recon-row.main .num { font-size: 13px; color: var(--green-900); }
.recon-cell-sub { font-size: 10px; color: var(--ink-3); }

.recon-reasons-title { font-size: 12px; font-weight: 700; color: var(--green-900); }

.recon-reason {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1px dotted var(--line);
}

.recon-reason .num { color: var(--red-500); font-weight: 600; white-space: nowrap; }

.panel-recon-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}

/* Responsive fallback */
@media (max-width: 1400px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .mid-row { grid-template-columns: 200px minmax(0, 1fr) 260px; }
}

@media (max-width: 1150px) {
  .mid-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}
