/* Shared visual language for the operations system. Business layouts stay in style.css. */
:root {
  --ui-bg: #f4f7f6;
  --ui-surface: #fff;
  --ui-surface-muted: #f5f8f6;
  --ui-line: #e0e8e4;
  --ui-line-soft: #edf2ee;
  --ui-ink: #253d32;
  --ui-muted: #6e8076;
  --ui-accent: #168a72;
  --ui-accent-dark: #126c54;
  --ui-accent-soft: #edf6f2;
  --ui-blue: #5276ba;
  --ui-up: #b42318;
  --ui-down: #0b7a55;
  --ui-warning: #996b28;
  --ui-radius: 14px;
  --ui-radius-sm: 9px;
  --ui-font: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  --bg: var(--ui-bg);
  --panel: var(--ui-surface);
  --ink: #17211f;
  --muted: var(--ui-muted);
  --line: var(--ui-line);
  --accent: var(--ui-accent);
  --accent-dark: var(--ui-accent-dark);
  --bad: var(--ui-up);
  --warn: var(--ui-warning);
}
body.app-ui { font-family: var(--ui-font); font-size: 14px; line-height: 1.6; }
.app-ui .content {
  min-width: 0;
  width: 100%;
  max-width: 1504px;
  margin: 0 auto;
  padding: 30px 36px 64px;
}
.app-ui .content :where(.page-head, .opt-head) {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  min-width: 0;
}
.app-ui .content :where(h1) { font-size: 28px; line-height: 1.4; letter-spacing: -.02em; font-weight: 700; }
.app-ui .content :where(h2) { font-size: 18px; line-height: 1.65; font-weight: 650; margin: 0 0 17px; color: var(--ui-ink); }
.app-ui .content :where(h3) { font-size: 14px; line-height: 1.7; font-weight: 650; color: #3e594b; margin: 22px 0 12px; }
.app-ui .content :where(.page-head p, .opt-head > div > p) { font-size: 13px; line-height: 1.85; color: var(--ui-muted); margin-top: 8px; max-width: 100ch; }
.app-ui .content :where(.panel, .filter-bar, .kpis > article) {
  border: 1px solid var(--ui-line);
  box-shadow: none;
  background: var(--ui-surface);
}
.app-ui .content :where(.panel) {
  border-radius: var(--ui-radius);
  padding: 24px 26px;
  margin-bottom: 22px;
  min-width: 0;
}
.app-ui .content :where(.panel > h2)::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 17px;
  margin-right: 10px;
  border-radius: 2px;
  background: #b9dacc;
  vertical-align: -2px;
}
.app-ui .content :where(.dashboard-grid, .two-col, .traffic-chart-grid, .promo-diagnosis-grid) { gap: 20px; min-width: 0; }
.app-ui .content :where(.dashboard-grid > *, .two-col > *, .traffic-chart-grid > *) { min-width: 0; }
.app-ui .content :where(.panel .panel, .change-compare-grid .panel) { padding: 18px; border-radius: 10px; margin-bottom: 14px; }
.app-ui .content :where(.filter-bar) {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  align-items: end;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
  border-radius: 12px;
  min-width: 0;
}
/* Override the old fixed-column region variants, so large filters can wrap. */
.app-ui .content :where(.filter-bar:has(.store-scope-select)) { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.app-ui:not(.diagnosis-page) .content .filter-bar { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.app-ui .content :where(.filter-bar > label) { min-width: 0; color: #637a6d; font-size: 12px; gap: 7px; }
.app-ui .content :where(.filter-bar > button) { min-height: 41px; }
.app-ui .content :where(label) { color: #5e7467; font-size: 13px; }
:where(.app-ui) :where(input, select, textarea, button) { font-family: var(--ui-font); }
.app-ui .content :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="color"]), select, textarea),
:where(.app-ui) .auth-panel :where(input, select, textarea) {
  min-width: 0;
  max-width: 100%;
  border: 1px solid #dce6df;
  border-radius: var(--ui-radius-sm);
  background: #fff;
  color: var(--ui-ink);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
:where(.app-ui) :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ui-accent); }
:where(.app-ui) :where(input, textarea)::placeholder { color: #8b9a91; font-weight: 400; }
.app-ui .content :where(input, select, textarea):focus,
:where(.app-ui) .auth-panel :where(input, select, textarea):focus { border-color: #6cae95; outline: 0; box-shadow: 0 0 0 3px #168a7212; }
.app-ui .content :where(button, .button-link),
:where(.app-ui) .auth-panel :where(button) {
  border-radius: var(--ui-radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: none;
  transition: background .15s, border-color .15s;
}
.app-ui .content :where(button:disabled, input:disabled, select:disabled) { cursor: not-allowed; opacity: .6; }
.app-ui .content :where(.muted-link, .muted-button) { background: #f3f7f4; color: #4e6859; border-color: #dce7df; }
.app-ui .content :where(.button-link:hover, button:hover) { filter: brightness(.97); }
:where(.app-ui) :where(button, a, summary):focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.app-ui .content :where(.store-select-search) { padding: 7px 11px; font-size: 12px; }
.app-ui .content :where(.checkbox-panel) { border-top-color: var(--ui-line-soft); padding-top: 14px; gap: 10px; min-width: 0; }
.app-ui .content :where(.check-item, .category-chip) { border-radius: 7px; font-size: 12px; padding: 7px 10px; }
.app-ui .content :where(.check-item:has(input:checked)) { background: var(--ui-accent-soft); border-color: #9ec9b6; color: var(--ui-accent-dark); }
.app-ui .content :where(.store-filter-region) { border-color: var(--ui-line); border-radius: 8px; }
.app-ui .content :where(.store-filter-region > summary) { background: #f6f9f7; color: #4b6958; padding: 10px 12px; font-size: 12px; }
.app-ui .content :where(.kpis) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.app-ui .content :where(.kpis > article) { border-radius: 12px; padding: 19px 21px; min-width: 0; }
.app-ui .content :where(.kpis > article:first-child) { border-color: #cde2d7; background: var(--ui-accent-soft); }
.app-ui .content :where(.kpis small) { font-size: 12px; color: #627a6b; line-height: 1.8; font-weight: 500; }
.app-ui .content :where(.kpis strong) { display: block; font-size: clamp(23px, 2.1vw, 32px); font-weight: 700; line-height: 1.3; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.app-ui .content :where(.kpis > article:first-child strong) { color: var(--ui-accent-dark); }
.app-ui .content :where(.kpis em) { margin-top: 8px; font-size: 12px; line-height: 1.8; font-style: normal; }
.app-ui .content :where(.kpis .ui-long-metric) { font-size: 18px; line-height: 1.65; letter-spacing: 0; }
.app-ui .content :where(.kpi-hint) { font-size: 10px; line-height: 1.6; padding: 1px 6px; background: #f2f6f3; color: #75877b; border-color: #e1eae3; }
.app-ui .content .kpis small .kpi-hint { display: inline-block; margin: 0 0 0 6px; padding: 0 6px; font-size: 10px; line-height: 1.6; }
.app-ui .content :where(.tab-nav, .product-status-tabs) {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 0 20px;
  padding: 0 16px;
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}
.app-ui .content :where(.tab-nav a, .product-status-tabs a) {
  padding: 12px 0 10px;
  margin: 0;
  border: 0;
  border-bottom: 3px solid transparent;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: #73857a;
  font-size: 13px;
  font-weight: 500;
}
.app-ui .content :where(.tab-nav a.active, .product-status-tabs a.active, .tab-nav a:hover, .product-status-tabs a:hover) { border-bottom-color: var(--ui-accent); color: var(--ui-accent-dark); background: transparent; }
.app-ui .content :is(.tab-nav, .product-status-tabs) > a { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; box-shadow: none; }
.app-ui .content :is(.tab-nav, .product-status-tabs) > a:is(.active, :hover) { border-bottom-color: var(--ui-accent); color: var(--ui-accent-dark); background: transparent; box-shadow: none; }
.app-ui .content :where(table) { font-size: 13px; font-variant-numeric: tabular-nums; border-spacing: 0; }
.app-ui .content :where(th) { font-size: 12px; font-weight: 500; line-height: 1.65; color: #687f70; background: var(--ui-surface-muted); text-align: center; border-bottom: 1px solid #dfe8e1; padding: 12px 11px; }
.app-ui .content :where(td) { line-height: 1.7; text-align: center; padding: 12px 11px; border-bottom: 1px solid var(--ui-line-soft); }
.app-ui .content :where(th:first-child, td:first-child) { text-align: left; }
.app-ui .content :where(tbody tr:last-child td) { border-bottom: 0; }
:where(.app-ui) .content :where(tbody tr:hover td) { background: #f8fbf9; }
.app-ui .content :where(.table-scroll, .wide-table, .opt-table) { min-width: 0; max-width: 100%; border-color: var(--ui-line); border-radius: 10px; scrollbar-width: thin; scrollbar-color: #cad8cf transparent; }
.app-ui .content :where(.table-scroll) { width: 100%; background: #fff; }
.app-ui .content :where(.table-scroll table:not(.matrix-table)) { min-width: 100%; width: 100%; }
.app-ui .content :where(.table-scroll th) { background: #f5f8f6; box-shadow: 0 1px 0 #e0e8e4; white-space: normal; }
.app-ui .content :where(.table-scroll table:not(.matrix-table) th) { min-width: 82px; }
.app-ui .content :where(.table-sort-btn) { font: inherit; padding: 0; line-height: inherit; border-radius: 0; }
.app-ui .content :where(.sortable-table th .table-sort-btn) { text-align: center; }
.app-ui .content :where(.sortable-table th:first-child .table-sort-btn) { text-align: left; }
.app-ui .content .sortable-table th .table-sort-btn { text-align: center; }
.app-ui .content .sortable-table th:first-child .table-sort-btn { text-align: left; }
.app-ui .content :where(.table-sort-btn)::after { font-size: 10px; opacity: .6; margin-left: 4px; }
.app-ui .content :where(.table-scroll input, .table-scroll select, .opt-table input, .opt-table select) { padding: 7px 9px; font-size: 12px; }
.app-ui .content :where(.table-scroll button:not(.table-sort-btn), .table-scroll .button-link) { padding: 6px 10px; font-size: 12px; }
.app-ui .content :where(.table-scroll table:not(.matrix-table) td:first-child) { padding-left: 16px; }
.app-ui .content :where(.status, .risk-pill, .opt-badge) { border-radius: 6px; font-size: 11px; line-height: 1.6; padding: 4px 8px; font-weight: 600; }
.app-ui .content :where(.hint, .opt-muted) { font-size: 12px; line-height: 1.85; }
.app-ui .content :where(.section-note, .opt-note) { font-size: 12px; line-height: 1.9; border-radius: 9px; padding: 12px 16px; margin-bottom: 18px; }
.app-ui .content :where(.empty) { font-size: 13px; line-height: 1.8; padding: 28px 16px; }
.app-ui .content :where(details.panel) { padding: 0; overflow: hidden; }
.app-ui .content :where(details.panel > summary) { list-style: none; padding: 19px 22px; cursor: pointer; color: #3e594b; font-size: 15px; font-weight: 600; }
.app-ui .content :where(details.panel > summary)::-webkit-details-marker { display: none; }
.app-ui .content :where(details.panel[open] > summary) { border-bottom: 1px solid var(--ui-line-soft); background: #f8faf9; margin-bottom: 18px; }
.app-ui .content :where(details.panel > :not(summary)) { margin-left: 22px; margin-right: 22px; }
.app-ui .content :where(details.panel > :last-child:not(summary)) { margin-bottom: 22px; }
.app-ui .content :where(.coverage-node, .coverage-platform, .rate-rule-card, .diagnosis-item, .optional-group-block, .bundle-picked-group) { border-radius: 10px; border-color: var(--ui-line); }
.app-ui .content :where(.coverage-node > summary, .coverage-platform > summary) { background: #f5f8f6; color: #567060; font-size: 13px; }
.app-ui .content :where(.cube-method-block, .cube-plan-card, .doujin-section, .change-before, .change-after) { border-radius: 10px; border-color: var(--ui-line); }
.app-ui .content :where(.cube-plan-title) { font-size: 19px; font-weight: 650; }
.app-ui .content :where(.cube-method-summary strong) { font-size: 17px; font-weight: 650; }
.app-ui .content :where(.cube-ref-item, .category-editor) { border-radius: 9px; background: #f4f8f5; }
.app-ui .content :where(.cube-ref-item small) { font-size: 12px; color: #75887a; }
:where(.app-ui) :where(dialog) { border: 1px solid var(--ui-line); border-radius: 16px; padding: 0; box-shadow: 0 20px 70px #122d2033; max-width: calc(100vw - 28px); }
:where(.app-ui) :where(dialog)::backdrop { background: #172d2555; backdrop-filter: blur(3px); }
.app-ui .column-order-dialog { width: min(520px, calc(100vw - 28px)); }
.app-ui .column-order-dialog .modal-card { width: 100%; max-width: none; }
:where(.app-ui) :where(.modal-card, .cube-time-dialog, .bundle-float-panel) { border-radius: 14px; border-color: var(--ui-line); box-shadow: 0 14px 45px #1734261f; }
:where(.app-ui) .sidebar { box-shadow: none; border-right-color: #243c31; }
:where(.app-ui) .sidebar :where(.sidebar-toggle, .brand-switcher, .brand-single) { border-radius: 10px; }
:where(.app-ui) .sidebar :where(a.active) { box-shadow: none; }
:where(.app-ui) .sidebar :where(.nav-group-title) { letter-spacing: .035em; }
:where(.app-ui) .page-load-timer { box-shadow: none; border-color: #e0e8e4; font-size: 11px; padding: 3px 8px; background: #ffffffed; }
/* Direction colors are shared. Existing risk/health colors keep their own semantics. */
.app-ui .content :where(.up, .pk-up, .promo-delta-up) { color: var(--ui-up); font-weight: 700; }
.app-ui .content :where(.down, .pk-down, .promo-delta-down) { color: var(--ui-down); font-weight: 700; }
.app-ui .content :where(.flat, .pk-flat, .promo-delta-flat) { color: var(--ui-muted); font-weight: 500; }
body.app-ui.auth-page { background: var(--ui-bg); padding: 24px 0; }
:where(.app-ui) .auth-panel { width: min(430px, calc(100vw - 32px)); }
:where(.app-ui) .auth-panel .panel { border-radius: 16px; padding: 30px; box-shadow: 0 12px 42px #1c3c290a; border-color: var(--ui-line); gap: 20px; }
:where(.app-ui) .auth-panel h1 { font-size: 25px; font-weight: 700; }
:where(.app-ui) .auth-panel label { color: #63786b; font-size: 13px; }
:where(.app-ui) .auth-brand { margin-bottom: 24px; }
:where(.app-ui) .auth-brand small { font-size: 12px; color: #7b8b80; }
/* Standalone export decks share colors and fonts without changing their fixed artboards. */
body.report-presentation { font-family: var(--ui-font); --teal: var(--ui-accent); --teal-dk: var(--ui-accent-dark); --teal-lt: var(--ui-accent-soft); --up: var(--ui-up); --down: var(--ui-down); }
.report-presentation :where(.slide:not(.cover)) { border-radius: 14px; }
.report-presentation :where(.box, .kpi, .dcard) { border-radius: 10px; border-color: var(--ui-line); }
.report-presentation :where(table) { font-variant-numeric: tabular-nums; }
@media (min-width: 1700px) {
  :where(.app-ui:not(.diagnosis-page)) .content :where(.kpis:not(.rate-result-kpis):not(.risk-kpis)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .app-ui .content { padding: 24px 22px 48px; }
  .app-ui .content :where(.panel) { padding: 21px; }
  .app-ui .content :where(.kpis > article) { padding: 17px; }
  .app-ui .content :where(.filter-bar, .filter-bar:has(.store-scope-select)) { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .app-ui .content :where(.product-admin, .product-setup-grid, .store-settings-grid) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app-ui .content :where(.kpis) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-ui .content :where(.dashboard-grid, .two-col, .traffic-chart-grid, .promo-diagnosis-grid, .change-compare-grid) { grid-template-columns: minmax(0, 1fr); }
  .app-ui .content :where(.cube-plan-fields, .cube-current-row, .cube-adjust-row, .mt-base-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :where(.app-ui) .sidebar { padding: 15px 18px; }
  :where(.app-ui) .sidebar :where(.brand) { margin-bottom: 18px; }
  :where(.app-ui) .sidebar :where(.nav-group-title) { margin-top: 4px; }
}
@media (max-width: 640px) {
  .app-ui .content { padding: 20px 12px 36px; }
  .app-ui .content :where(h1) { font-size: 23px; }
  .app-ui .content :where(h2) { font-size: 17px; }
  .app-ui .content :where(.page-head, .opt-head) { flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
  .app-ui .content :where(.panel) { padding: 18px 15px; border-radius: 12px; margin-bottom: 16px; }
  .app-ui .content :where(.filter-bar, .filter-bar:has(.store-scope-select)) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; margin-bottom: 16px; }
  .app-ui:not(.diagnosis-page) .content .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-ui .content :where(.filter-bar > button) { grid-column: 1 / -1; }
  .app-ui .content :where(.checkbox-panel, .pk-options) { grid-column: 1 / -1; min-width: 0; }
  .app-ui .content :where(.checkbox-grid) { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .app-ui .content :where(.kpis) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
  .app-ui .content :where(.kpis > article) { padding: 15px; border-radius: 10px; }
  .app-ui .content :where(.kpis strong) { font-size: 23px; }
  .app-ui .content :where(.kpis .ui-long-metric) { font-size: 15px; }
  .app-ui .content :where(.tab-nav, .product-status-tabs) { flex-wrap: nowrap; overflow-x: auto; padding: 0 12px; gap: 18px; scrollbar-width: thin; }
  .app-ui .content :where(.tab-nav a, .product-status-tabs a) { white-space: nowrap; font-size: 12px; }
  .app-ui .content :where(.import-upload-form, .admin-search-bar, .cube-plan-fields, .cube-current-row, .cube-adjust-row, .doujin-grid, .mt-base-grid, .category-editor, .change-line) { grid-template-columns: minmax(0, 1fr); }
  .app-ui .content :where(.coverage-node > summary, .coverage-platform > summary) { font-size: 12px; }
  .app-ui .content :where(.table-scroll) { max-height: min(72vh, 560px); }
  .app-ui .content :where(th, td) { padding: 10px; font-size: 12px; }
  .app-ui .content :where(details.panel) { padding: 0; }
  .app-ui .content :where(details.panel > :not(summary)) { margin-left: 14px; margin-right: 14px; }
  .app-ui .content :where(details.panel > summary) { padding: 16px 14px; }
  .app-ui .content :where(.modal-card, .cube-time-dialog) { max-width: calc(100vw - 24px); padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  :where(.app-ui) *, :where(.app-ui) *::before, :where(.app-ui) *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
}
@media print {
  body.app-ui { display: block; background: #fff; }
  :where(.app-ui) .sidebar, :where(.app-ui) .page-load-timer { display: none; }
  .app-ui .content { width: 100%; max-width: none; padding: 0; }
  .app-ui .content :where(.panel, .kpis > article) { box-shadow: none; border-color: #ddd; }
  .app-ui .content :where(tr, .kpis > article) { break-inside: avoid; }
  .app-ui .content :where(.table-scroll) { overflow: visible; max-height: none; }
}
