/* UI v2 design foundation. Loaded last; the single source of design tokens.
 * Rules and ownership: docs/ui-v2/DIRECTION.md */

:root,
html[data-ui="integrated-core"] body {
  --fs-1: 12px;
  --fs-2: 13px;
  --fs-3: 15px;
  --fs-4: 18px;
  --fs-5: 24px;
  --fs-hero: 36px;
  --font-size-xs: var(--fs-1);
  --font-size-sm: var(--fs-1);
  --font-size-md: var(--fs-2);
  --font-size-lg: var(--fs-3);
  --font-size-xl: var(--fs-4);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --radius-sm: var(--r-sm);
  --radius: var(--r-md);
  --radius-lg: var(--r-lg);

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --border: #e6e8ee;
  --border-strong: #d5d9e1;
  --text: #172238;
  --text-2: #4d5b6e;
  --text-3: #6b7686;

  --hatch: repeating-linear-gradient(135deg, transparent 0 4px, rgba(107, 118, 134, .22) 4px 5px);
}

html[data-ui="integrated-core"] body {
  font-size: var(--fs-2);
  background: var(--bg);
}

/* Missing values: one visual everywhere, reason lives in title. */
.no-data {
  color: var(--text-3);
  text-decoration: underline dotted rgba(107, 118, 134, .55);
  text-underline-offset: 3px;
}
.no-data[title] { cursor: help; }
.is-missing {
  background-color: var(--surface-2) !important;
  background-image: var(--hatch) !important;
  color: var(--text-3);
}

/* Numbers line up in tables and KPI cards. */
:is(td.num, th.num, .num, .stat-value, .merch-kpi-card > strong, .ui-stat-card > strong,
    .ioh-summary-stat > strong, .dw-facts strong, .growth-stat > strong) {
  font-variant-numeric: tabular-nums;
}

/* Segmented scope switches must not wrap onto the next field. */
.merch-scope-switch {
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.merch-scope-switch > button { flex: 0 0 auto; white-space: nowrap; }

/* "Show more" rows below paged lists. */
.content-more,
.rhythm-more,
[data-uiv2-more] {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

/* Sidebar footer: account chip only. */
.sidebar .side-foot-meta { display: none; }

/* 经营总览：店铺 × 数据源完整度矩阵，替代两排状态标签。 */
.report-data-matrix {
  display: grid;
  gap: 4px;
  margin: 14px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.report-data-matrix .rdm-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) repeat(4, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}
.report-data-matrix [role="rowheader"] {
  align-self: center;
  color: var(--text);
  font-size: var(--fs-2);
  font-weight: 550;
}
.report-data-matrix .rdm-head > span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 4px;
  color: var(--text-3);
  font-size: var(--fs-1);
}
.report-data-matrix .rdm-head b { color: var(--text-2); font-weight: 600; }
.report-data-matrix .rdm-cell {
  display: grid;
  place-items: center;
  min-height: 28px;
  border-radius: var(--r-sm);
  font-size: var(--fs-1);
}
.report-data-matrix .rdm-cell.is-ready { background: rgba(22, 128, 72, .09); color: #146c3f; }
.report-data-matrix .rdm-cell.is-missing {
  background-color: var(--surface-2);
  background-image: var(--hatch);
  color: var(--danger, #b42318);
  font-weight: 600;
}
.report-data-matrix .rdm-cell.is-na { color: var(--text-3); }
.report-data-matrix .rdm-foot { justify-self: end; padding-top: 4px; color: var(--text-3); font-size: var(--fs-1); }
@media (max-width: 640px) {
  .report-data-matrix .rdm-row { grid-template-columns: minmax(84px, 1fr) repeat(4, minmax(44px, 1fr)); }
  .report-data-matrix .rdm-head small { display: none; }
}

/* 我的工作 · 总览：一句话总结 + 一个焦点卡（阻塞 / 逾期），其余降为次要。 */
.ioh-brief {
  margin: 2px 0 14px;
  color: var(--text-2);
  font-size: var(--fs-3);
  line-height: 1.6;
}
.ioh-brief b { color: var(--danger, #b42318); font-weight: 600; }
.ioh-summary-band.is-v2 {
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.ioh-summary-band.is-v2 .ioh-summary-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.ioh-summary-band.is-v2 .ioh-summary-stat strong { margin: 0; font-size: var(--fs-4); }
.ioh-summary-band.is-v2 .ioh-summary-stat small { color: var(--text-3); font-size: var(--fs-1); }
.ioh-summary-band.is-v2 .ioh-summary-stat.is-hero {
  grid-column: 1;
  grid-row: 1 / span 3;
  gap: 6px;
  padding: 18px 20px;
}
.ioh-summary-band.is-v2 .ioh-summary-stat.is-hero strong {
  font-size: var(--fs-hero);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.ioh-summary-band.is-v2 .ioh-summary-stat:not(.is-hero) { grid-column: span 3; flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 10px; }
.ioh-summary-band.is-v2 .ioh-summary-stat:not(.is-hero) > span { min-width: 7em; }
.ioh-summary-band.is-v2 .ioh-summary-stat:not(.is-hero) small { flex-basis: 100%; }
.ioh-summary-stat .ioh-risk-bar {
  display: flex;
  gap: 2px;
  height: 10px;
  margin-top: auto;
  padding-top: 12px;
  box-sizing: content-box;
}
.ioh-summary-stat .ioh-risk-bar i { display: block; min-width: 3px; border-radius: 3px; background: var(--danger, #b42318); }
.ioh-summary-stat .ioh-risk-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); font-size: var(--fs-1); }
.ioh-summary-stat .ioh-risk-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.ioh-summary-stat .ioh-risk-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--danger, #b42318); }
@media (max-width: 1080px) {
  .ioh-summary-band.is-v2 { grid-template-columns: 1fr; }
  .ioh-summary-band.is-v2 .ioh-summary-stat.is-hero,
  .ioh-summary-band.is-v2 .ioh-summary-stat:not(.is-hero) { grid-column: 1; grid-row: auto; }
  .ioh-summary-band.is-v2 .ioh-summary-stat.is-hero { order: -1; }
}

/* Confirmed prototype: glass, glow soft, surfaces solid.
   Applies to every integrated-core page. Classic (?ui=classic) is unchanged.
   Page-specific tables and charts keep their own layout. */
html[data-ui="integrated-core"] body {
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 18px;
  --radius-sm: 12px;
  --radius: 10px;
  --radius-lg: 18px;
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, .9), 0 0 0 1px rgba(15, 23, 42, .05);
  --glass-shadow: var(--glass-edge), 0 12px 32px -12px rgba(30, 41, 74, .14);
  --bg: #eef0f4;
  --workspace-bg: transparent;
  --sidebar: rgba(255, 255, 255, .62);
  --surface: rgba(255, 255, 255, .78);
  --surface-2: rgba(241, 243, 248, .72);
  --border: rgba(15, 23, 42, .07);
  --shadow-sm: var(--glass-shadow);
  --shadow-md: var(--glass-edge), 0 18px 40px -16px rgba(30, 41, 74, .18);
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(120, 150, 255, .20), transparent 60%),
    radial-gradient(760px 520px at 96% 10%, rgba(255, 170, 120, .16), transparent 62%),
    radial-gradient(900px 700px at 70% 110%, rgba(110, 220, 200, .14), transparent 60%),
    #eef0f4;
  background-attachment: fixed;
}
html[data-ui="integrated-core"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(29, 43, 79, .10) 1px, transparent 1.2px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .65), transparent 78%);
}
html[data-ui="integrated-core"] body .layout { position: relative; z-index: 1; background: transparent; }
html[data-ui="integrated-core"] body .site-topbar {
  background: transparent;
  border-bottom: 0;
  box-shadow: none;
}
@media (min-width: 801px) {
  html[data-ui="integrated-core"] body .sidebar {
    margin: 12px 0 12px 12px;
    height: calc(100vh - 24px);
    border: 0;
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, .62);
    box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: blur(22px) saturate(1.4);
    backdrop-filter: blur(22px) saturate(1.4);
  }
  html[data-ui="integrated-core"] body .sidebar .logo { border-bottom-color: transparent; }
}
html[data-ui="integrated-core"] body .sidebar nav a.active {
  background: linear-gradient(180deg, #25365f, #1a2645);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(29, 43, 79, .5), inset 0 1px 0 rgba(255, 255, 255, .15);
}
html[data-ui="integrated-core"] body :is(
  .card, .ui-panel, .ioh-panel, .ioh-management-card, .ish-card, .role-workspace-panel,
  .swc-panel, .fc-card, .pl-card, .pace-performance-card, .pace-store-card,
  .uw-card, .uw-focus-panel, .account-role-card,
  .development-document-card, .development-task-card, .dw-panel,
  .season-map-card, .season-portfolio-card, .sel-card,
  .growth-panel, .automation-coverage-card, .automation-flow-card,
  .pub-panel, .content-exp-panel, .merch-overview-panel, .merch-queue-panel,
  .stat-card, .ui-stat-card, .ioh-summary-stat, .merch-summary-card, .growth-stat
) {
  border: 0;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--glass-shadow);
}
html[data-ui="integrated-core"] body :is(.page-header, .uw-page-header, .fc-page-header, .automation-page-header, .season-page-header) {
  background: transparent;
}
.uiv2-flash, .uiv2-close-lead {
  display: grid;
  grid-template-columns: minmax(240px, .9fr) minmax(0, 1.6fr);
  gap: 16px;
  margin: 0 0 16px;
  padding: 18px;
  border-radius: var(--r-lg, 26px);
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--glass-shadow, 0 12px 32px -12px rgba(30, 41, 74, .14));
}
.uiv2-flash-kicker { color: var(--text-3); font-size: var(--fs-1); }
.uiv2-flash-sentence, .sel-lead { margin: 4px 0 10px; font-size: var(--fs-2); font-weight: 500; line-height: 1.55; color: var(--text-2); }
.uiv2-fold { margin: 12px 0; padding: 8px 14px 12px; border-radius: var(--r-md, 18px); background: rgba(255,255,255,.72); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06); }
.uiv2-fold > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-3); }
.uiv2-flash-note { margin: 0; color: var(--text-3); font-size: var(--fs-1); }
.uiv2-flash-heads, .uiv2-flash-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.uiv2-flash-cell, .uiv2-flash-groups span {
  display: grid;
  gap: 2px;
  min-width: 108px;
  padding: 10px 12px;
  border-radius: var(--r-md, 18px);
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .05);
}
.uiv2-flash-cell small, .uiv2-flash-groups small { color: var(--text-3); font-size: var(--fs-1); }
.uiv2-flash-cell strong, .uiv2-flash-groups b { font-size: var(--fs-4); font-weight: 500; font-variant-numeric: tabular-nums; }
.uiv2-flash-cell strong.is-neg { color: var(--danger, #b42318); }
.uiv2-flash-groups { margin-top: 12px; }
.uiv2-close-queue { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.uiv2-close-queue li { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; align-items: start; }
.uiv2-close-queue small { display: block; color: var(--text-3); }
.uiv2-kind { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-1); font-weight: 600; text-align: center; }
.uiv2-kind.is-miss { background: rgba(220, 38, 38, .12); color: #991b1b; }
.uiv2-kind.is-break { background: rgba(220, 38, 38, .18); color: #7f1d1d; }
.uiv2-kind.is-time { background: rgba(217, 119, 6, .14); color: #9a3412; }
.season-parallel-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.uiv2-view-job {
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: var(--r-md, 18px);
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--glass-shadow, 0 8px 24px -12px rgba(30, 41, 74, .12));
  color: var(--text, #141824);
  font-size: var(--fs-2, 13px);
  line-height: 1.55;
}
@media (max-width: 1100px) {
  .uiv2-flash, .uiv2-close-lead, .season-parallel-grid { grid-template-columns: 1fr; }
}

/* Canvas / templates / components stay in the editor iframe. The frame itself
   uses the same page ground as the hub, without a second card chrome. */
html[data-ui="integrated-core"] .integrated-studio-frame-wrap,
html[data-ui="integrated-core"] .integrated-studio-frame,
html[data-ui="integrated-core"] .integrated-studio-loading {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}
html[data-ui="integrated-core"] .integrated-studio-frame { opacity: 1; }
