/*
 * Overview page. The left work column groups actions, and the right column
 * groups financial and activity references. Theme aliases stay within this view.
 *
 * Class contract (index.html owns the markup, this file owns the look):
 *   .ov                      root wrapper inside <section id="dashboard">
 *   .ov-head                 greeting block; children .ov-greet .ov-quote .ov-clock
 *   .ov-clock                clock block; children .ov-clock-d .ov-clock-t
 *   .ov-block               一个白底块（今天要处理 / 待收款 …）
 *   .ov-block-head          块头：.ov-block-title .ov-block-sub .ov-link
 *   .ov-count               块头里的数字
 *   .ov-list > .ov-row      44px 待办行：.ov-st .ov-title .ov-meta .ov-row-act
 *   .ov-priority            AI 重点客户待跟进
 *   .ov-row-2               两列并排（2fr 1fr）
 *   .ov-big                 关键数字行：.ov-big-num .ov-big-label
 *   .ov-lines > .ov-line    40px 明细行：.ov-line-name .ov-amt .ov-age
 *   .ov-line > .ov-stage    阶段行：.ov-name .ov-tag
 *   .ov-chart > .ov-bars > .ov-col > .ov-v + .ov-bar(.is-today)
 *   .ov-x                   日期刻度行
 *   .ov-note                块底小字（事实 / 动作，不写解释话术）
 *   .ov-empty / .ov-err     空态与错态的一行字
 */

/* ---------- Root rhythm ---------- */
#dashboard.ov {
  --tv-surface: #fffefa;
  --tv-subtle: #f1f6f0;
  --tv-surface-hover: #edf6ef;
  --tv-border: #dce5de;
  --tv-border-strong: #a5bcb1;
  --tv-control-border: #899f96;
  --tv-text: #172d32;
  --tv-text-2: #365159;
  --tv-text-3: #526663;
  --tv-brand: #08695f;
  --tv-brand-hover: #064d47;
  --tv-brand-soft: #dff4f1;
  --tv-brand-ring: #08695f35;
  --tv-info: #59459a;
  --tv-info-bg: #f0ebf8;
  --ov-gap: clamp(12px, 1.4vw, 20px);
  --ov-work-tint: #eaf5ec;
  --ov-reference-tint: #f4f7f2;
  --ov-ledger-tint: #eaf4ef;
  color: var(--tv-text);
}

#dashboard.ov:not(.hidden):has(#dashboardReceivables) {
  grid-template-columns: minmax(0, 1.62fr) minmax(265px, 1fr);
  align-items: start;
  gap: var(--ov-gap);
}

#dashboard.ov #dashboardOverview {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#dashboard.ov .ov-stack {
  display: grid;
  min-width: 0;
  gap: var(--ov-gap);
}

#dashboardOverview > .ov-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tv-s2);
  margin-block-end: var(--ov-gap);
  padding: var(--tv-s3) var(--tv-s4);
  border: 1px solid var(--tv-danger-border);
  border-radius: var(--tv-radius);
  background: var(--tv-danger-bg);
  color: var(--tv-danger);
  font-size: var(--tv-fs-md);
}

#dashboardOverview > [aria-labelledby="ovStageTitle"] {
  margin-block-start: var(--ov-gap);
}

#dashboardOverview .ov-today {
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

#dashboardOverview .ov-priority {
  border-block-start: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

/* ---------- Head: greeting + clock ---------- */
.ov-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-s5);
  position: relative;
  isolation: isolate;
  min-height: 140px;
  padding: var(--tv-s4) clamp(18px, 2.7vw, 38px);
  overflow: hidden;
  border: 1px solid #ccdcd2;
  border-radius: var(--tv-radius-feature);
  background: linear-gradient(105deg, #f7faf3, var(--ov-work-tint) 60%);
  color: var(--tv-text);
}

.ov-head::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 0 39%;
  background: url("/brand/overview-fold.webp") center 54% / cover no-repeat;
  mask-image: linear-gradient(to right, transparent 26%, #000 56%);
  pointer-events: none;
}

.ov-greet {
  min-width: 0;
  width: min(54%, 66ch);
  margin: 0;
}

.ov-greet h1 {
  margin: 0;
  color: var(--tv-text);
  font-family: var(--tv-font-editorial);
  font-size: clamp(30px, 3.45vw, 46px);
  font-weight: 600;
  line-height: 1.13;
  letter-spacing: -.032em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.ov-quote {
  margin: var(--tv-s1) 0 0;
  font-size: var(--tv-fs-md);
  line-height: 1.5;
  color: var(--tv-text-2);
  overflow-wrap: anywhere;
}

.ov-quote strong {
  font-weight: inherit;
  color: inherit;
}

.ov-search-action {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-s2);
  min-height: var(--tv-control-h-md);
  padding-inline: var(--tv-s3);
  margin-top: var(--tv-s2);
  border-radius: var(--tv-radius-sm);
  background: var(--tv-brand);
  color: var(--tv-on-brand);
  font-size: var(--tv-fs-md);
  font-weight: 700;
  text-decoration: none;
  transition: background var(--tv-motion), transform var(--tv-motion);
}

#dashboard .ov-search-action:hover { background: var(--tv-brand-hover); color: var(--tv-on-brand); text-decoration: none; }
.ov-search-action:active { transform: translateY(1px); }
.ov-search-action:focus-visible { outline: 2px solid var(--tv-brand); outline-offset: 3px; }

.ov-clock {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  max-width: 42%;
  text-align: end;
}

.ov-clock-d {
  margin: var(--tv-s1) 0 0;
  font-size: var(--tv-fs-body);
  line-height: 1.45;
  color: var(--tv-text);
  font-weight: 500;
}

.ov-clock-t {
  margin: 0;
  color: var(--tv-text);
  font-size: clamp(26px, 2.65vw, 37px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: .01em;
  font-variant-numeric: var(--tv-numerals);
  font-feature-settings: "tnum" 1;
}

/* ---------- Blocks ---------- */
.ov-block {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-lg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ov-today {
  border-block-start-color: #aecbb8;
}

.ov-today .ov-block-head {
  border-start-start-radius: inherit;
  border-start-end-radius: inherit;
  background: var(--ov-work-tint);
}

.ov-today .ov-count {
  padding: 0 8px;
  border-radius: var(--tv-radius-full);
  background: #dceee2;
  color: var(--tv-brand-hover);
  font-size: var(--tv-fs-md);
}

.ov-today .ov-row:has(.is-overdue),
.ov-today .ov-row:has(.is-pending) {
  background: #fcf7ee;
}

.ov-today .ov-row:has(.is-overdue):hover,
.ov-today .ov-row:has(.is-pending):hover {
  background: #f9efdf;
}

#dashboardOverview .ov-priority-head {
  padding-block-start: var(--tv-s4);
  border-block-start: 1px solid var(--tv-border);
}

#ovFollowTitle {
  color: var(--tv-info);
}

#ovTodayTitle {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-s2);
}

#ovTodayTitle .ph { color: var(--tv-brand); }

.ov-block-head {
  display: flex;
  align-items: baseline;
  gap: var(--tv-s2);
  padding: var(--tv-s4) var(--tv-s5) var(--tv-s3);
}

.ov-block-title {
  margin: 0;
  font-size: var(--tv-fs-xl);
  line-height: 1.3;
  font-weight: 650;
}

.ov-count {
  font-size: var(--tv-fs-lg);
  line-height: 22px;
  font-weight: 600;
  color: var(--tv-text-2);
  font-variant-numeric: var(--tv-numerals);
}

.ov-block-sub {
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-2);
}

.ov-link {
  margin-left: auto;
  font-size: var(--tv-fs-md);
  line-height: 16px;
  font-weight: 500;
  color: var(--tv-brand);
  text-decoration: none;
  white-space: nowrap;
}

/* 同一套链接样式也用在 <button> 上（展开全部、排上）：
 * 必须清掉 UA 的边框、底色、内边距，否则会渲染成一颗描边按钮 */
.ov-link:any-link,
a.ov-link,
button.ov-link {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
  line-height: inherit;
  cursor: pointer;
  font-family: inherit;
}

.ov-link:hover {
  text-decoration: underline;
}

.ov-link:focus-visible {
  outline: 2px solid var(--tv-brand);
  outline-offset: 2px;
  border-radius: var(--tv-radius-xs);
}

/* ---------- 今天要处理：44px 两行任务行 ---------- */
.ov-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ov-row {
  display: flex;
  align-items: center;
  gap: var(--tv-s3);
  min-height: 49px;
  padding: var(--tv-s2) var(--tv-s5);
  border-top: 1px solid var(--tv-border);
}

.ov-row:hover {
  background: var(--tv-surface-hover);
}

.ov-st {
  flex: 0 0 clamp(64px, 9vw, 92px);
  font-size: var(--tv-fs-md);
  line-height: 1.35;
  overflow-wrap: anywhere;
  color: var(--tv-text-2);
  font-variant-numeric: var(--tv-numerals);
}

/* 逾期只上文字色，不铺色块 */
.ov-st.is-overdue {
  color: var(--tv-danger);
  font-weight: 650;
}

.ov-st.is-pending {
  color: var(--tv-warning);
  font-weight: 600;
}

.ov-title {
  display: block;
  font-size: var(--tv-fs-md);
  line-height: 18px;
  font-weight: 600;
  color: var(--tv-text);
  overflow-wrap: anywhere;
}

.ov-meta {
  display: block;
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-2);
  overflow-wrap: anywhere;
}

.ov-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.ov-row-act {
  flex: 0 0 auto;
  font-size: var(--tv-fs-md);
  font-weight: 650;
  text-align: end;
}

/* ---------- AI 重点客户待跟进 ---------- */
.ov-priority { container-type: inline-size; }
.ov-priority-head { align-items: center; }
.ov-priority-count,
.ov-priority-stage,
.ov-priority-urgent {
  padding: 2px var(--tv-s2);
  border-radius: var(--tv-radius-full);
  background: var(--tv-subtle);
  color: var(--tv-text-2);
  font-size: var(--tv-fs-sm);
  font-variant-numeric: var(--tv-numerals);
  line-height: 1.5;
}
.ov-priority-count {
  background: var(--tv-info-bg);
  color: var(--tv-info);
  font-weight: 650;
}
.ov-priority-urgent {
  background: var(--tv-info-bg);
  color: var(--tv-info);
  font-weight: 650;
}
.ov-priority-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ov-priority-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--tv-s2) var(--tv-s4);
  padding: var(--tv-s3) var(--tv-s5);
  border-top: 1px solid var(--tv-border);
}
.ov-priority-row:has(.ov-priority-urgent) {
  background: #faf7fc;
}
.ov-priority-main { display: grid; gap: var(--tv-s1); overflow-wrap: anywhere; }
.ov-priority-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--tv-s1) var(--tv-s2);
}
.ov-priority-customer {
  color: var(--tv-text-2);
  font-size: var(--tv-fs-md);
  font-weight: 650;
  text-decoration: none;
}
a.ov-priority-customer:hover { color: var(--tv-brand); text-decoration: underline; }
.ov-priority-action,
.ov-priority-reason { margin: 0; line-height: 1.55; }
.ov-priority-action { color: var(--tv-text); font-size: var(--tv-fs-body); font-weight: 650; }
.ov-priority-reason { max-width: 72ch; color: var(--tv-text-2); font-size: var(--tv-fs-md); }
.ov-priority-date {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-s1);
  margin-top: var(--tv-s1);
  color: var(--tv-text-2);
  font-size: var(--tv-fs-sm);
  font-variant-numeric: var(--tv-numerals);
}
.ov-priority-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tv-s1); }
.ov-priority button:is(.ov-priority-draft,.ov-priority-dismiss,.ov-priority-more) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tv-s1);
  min-height: var(--tv-control-h-md);
  margin: 0;
  padding: 0 var(--tv-s2);
  border: 1px solid transparent;
  border-radius: var(--tv-radius);
  background: transparent;
  color: var(--tv-text-2);
  font: 550 var(--tv-fs-md)/1.4 var(--tv-font);
  box-shadow: none;
}
.ov-priority button.ov-priority-draft {
  border-color: #bdd8c7;
  background: var(--ov-work-tint);
  color: var(--tv-brand-hover);
}
.ov-priority button.ov-priority-more {
  margin-inline-start: auto;
  color: var(--tv-brand);
}
.ov-priority-more[aria-expanded="true"] .ph { transform: rotate(180deg); }
.ov-priority button:is(.ov-priority-draft,.ov-priority-dismiss,.ov-priority-more):hover:enabled {
  background: var(--tv-brand-soft);
  color: var(--tv-brand-hover);
}
.ov-priority button:is(.ov-priority-draft,.ov-priority-dismiss,.ov-priority-more):disabled {
  opacity: .6;
  cursor: wait;
}
.ov-priority :is(button,a,h2):focus-visible {
  outline: 2px solid var(--tv-brand);
  outline-offset: 2px;
}
.ov-priority-state,
.ov-priority-feedback {
  margin: 0;
  padding: var(--tv-s3) var(--tv-s5);
  border-top: 1px solid var(--tv-border);
  color: var(--tv-text-2);
  font-size: var(--tv-fs-md);
}
.ov-priority-feedback.is-error { color: var(--tv-danger); }
@container (max-width: 468px) {
  .ov-priority-row { grid-template-columns: minmax(0, 1fr); padding-inline: var(--tv-s4); }
  .ov-priority-state,
  .ov-priority-feedback { padding-inline: var(--tv-s4); }
}

/* 块头里那句说明另起一行，不和标题、计数挤在一排 */
.ov-block-head {
  flex-wrap: wrap;
}

.ov-block-sub {
  flex: 1 1 100%;
  margin: 2px 0 0;
}

/* ---------- 两列并排：统一 2fr 1fr ---------- */
.ov-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--tv-s6);
  align-items: stretch;
}

/* ---------- 件数 / 金额大字 ---------- */
.ov-big {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--tv-s1) var(--tv-s2);
  margin: var(--tv-s2) var(--tv-s5) 0;
}

.ov-big-num {
  font-size: var(--tv-fs-title);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: var(--tv-numerals);
}

#dashboardReceivables .ov-money {
  border-color: #bdd6c9;
  --tv-fs-display: clamp(22px, 2.25vw, 31px);
}

.ov-money .ov-big {
  margin: 0;
  padding: var(--tv-s3) var(--tv-s5);
  background: var(--ov-ledger-tint);
}

#dashboardReceivables .ov-big-num {
  color: var(--tv-brand-hover);
  overflow-wrap: anywhere;
}

.ov-money .ov-lines { margin-top: 0; }

.ov-money-group + .ov-money-group {
  border-block-start: 1px solid #bdd6c9;
}

.ov-money-group:last-child {
  padding-block-end: var(--tv-s1);
}

#dashboardTrend .ov-block,
#gardenPanels .fx-panel,
#dashboardOverview > [aria-labelledby="ovStageTitle"] {
  background: var(--ov-reference-tint);
}

#dashboardTrend .ov-block-title,
#gardenPanels .ov-block-title,
#ovStageTitle {
  font-size: var(--tv-fs-lg);
}

#gardenPanels .fx-panel #fxRate {
  margin-block: 0;
  padding-block: var(--tv-s2) var(--tv-s3);
  background: var(--tv-surface);
}

.ov-money-scope {
  color: var(--tv-text-3);
}

.ov-big-label {
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-2);
}

/* ---------- 明细行：40px，金额右对齐，账龄次级 ---------- */
.ov-lines {
  display: flex;
  flex-direction: column;
  margin-top: var(--tv-s2);
}

.ov-line {
  display: flex;
  align-items: center;
  gap: var(--tv-s2);
  min-height: 40px;
  padding: 7px var(--tv-s5);
  border-top: 1px solid var(--tv-border);
  font-size: var(--tv-fs-md);
  line-height: 18px;
}

.ov-line-name {
  min-width: 0;
  color: var(--tv-text-2);
  overflow-wrap: anywhere;
}

.ov-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ov-amt {
  margin-left: auto;
  font-weight: 500;
  font-variant-numeric: var(--tv-numerals);
  white-space: nowrap;
}

.ov-age {
  flex: 0 0 38px;
  text-align: end;
  font-size: var(--tv-fs-md);
  color: var(--tv-text-3);
  font-variant-numeric: var(--tv-numerals);
}

/* 阶段标签：4px 圆角、细边、无底色 */
.ov-tag {
  display: inline-block;
  height: 20px;
  line-height: 18px;
  padding: 0 6px;
  border: 1px solid var(--tv-border-strong);
  border-radius: var(--tv-radius-xs);
  font-size: var(--tv-fs-md);
  color: var(--tv-text-2);
  white-space: nowrap;
}

.ov-sub {
  margin: var(--tv-s1) var(--tv-s4) 0;
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-2);
}

.ov-note {
  margin: 0 var(--tv-s5) var(--tv-s2);
  font-size: var(--tv-fs-md);
  color: var(--tv-text-2);
}

.ov-trend-today {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--tv-s1) var(--tv-s2);
  padding: var(--tv-s2) var(--tv-s4) var(--tv-s3);
  color: var(--tv-text-2);
  font-size: var(--tv-fs-md);
  font-variant-numeric: var(--tv-numerals);
}

.ov-trend-today strong { color: var(--tv-text); }

.ov-is-loading::after {
  content: "";
  display: block;
  width: min(160px, 55%);
  height: 6px;
  margin-block-start: var(--tv-s2);
  border-radius: var(--tv-radius-full);
  background: var(--tv-border);
}


/* ---------- 最近 7 天：柱顶数值，零值留 2px 底线 ---------- */
.ov-chart {
  margin: var(--tv-s1) var(--tv-s4) 0;
}

.ov-bars {
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, .65vw, 10px);
  min-height: 124px;
  border-bottom: 1px solid var(--tv-border);
  padding-bottom: 1px;
}

.ov-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.ov-v {
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-3);
  font-variant-numeric: var(--tv-numerals);
}

.ov-col.is-today .ov-v {
  color: var(--tv-text);
  font-weight: 500;
}

.ov-bar {
  width: 100%;
  max-width: 38px;
  min-height: 2px;
  background: var(--tv-border-strong);
  border-radius: 2px 2px 0 0;
}

.ov-bar.is-today {
  background: var(--tv-brand);
}

.ov-x {
  display: flex;
  gap: var(--tv-s3);
  margin-top: var(--tv-s1);
  font-size: var(--tv-fs-sm);
  font-variant-numeric: var(--tv-numerals);
}

.ov-x span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-3);
  font-variant-numeric: var(--tv-numerals);
}

/* ---------- 空态 / 错态：一行字，不用插画 ---------- */
.ov-empty,
.ov-err {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--tv-s2) var(--tv-s4);
  margin: 0;
  padding: var(--tv-s3) var(--tv-s5) var(--tv-s4);
  border-top: 1px solid var(--tv-border);
}

.ov-empty p,
.ov-err p {
  margin: 0;
  font-size: var(--tv-fs-md);
  line-height: 16px;
  color: var(--tv-text-2);
  max-width: 720px;
}

.ov-empty strong,
.ov-err strong {
  font-weight: 500;
  color: var(--tv-text);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1080px) {
  .ov-row-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 940px) {
  #dashboard.ov:not(.hidden):has(#dashboardReceivables) {
    grid-template-columns: minmax(0, 1fr);
  }

  #dashboard.ov > .ov-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 640px) {
  #dashboard.ov > .ov-stack { grid-template-columns: minmax(0, 1fr); }

  .ov-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--tv-s3);
    min-height: 148px;
    padding: var(--tv-s4);
    border-radius: var(--tv-radius-lg);
  }

  .ov-greet { width: 100%; }

  .ov-head::before {
    inset-inline-start: 49%;
    opacity: .20;
  }

  .ov-clock {
    flex-basis: 100%;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px var(--tv-s2);
    max-width: 100%;
    min-width: 0;
    text-align: start;
  }

  .ov-search-action { min-height: 44px; }
  .ov-block-head { padding-inline: var(--tv-s4); }
  .ov-bars { gap: var(--tv-s1); }

  .ov-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 2px var(--tv-s3);
    padding-inline: var(--tv-s4);
  }

  .ov-row-main { grid-column: 1 / -1; grid-row: 2; }
  .ov-row-act { grid-column: 2; grid-row: 1; }
  .ov-line { padding-inline: var(--tv-s4); }
}

@media (forced-colors: active) {
  .ov-head::before { display: none; }
  .ov-bar, .ov-count { border: 1px solid CanvasText; }
  .ov-priority-row:has(.ov-priority-urgent) { border-inline-start: 1px solid CanvasText; }
  .ov-search-action:focus-visible { outline-color: Highlight; }
}

@media (prefers-reduced-motion: reduce) {
  .ov-search-action { transition: none; }
  .ov-search-action:active { transform: none; }
}
