:root {
  color-scheme: light;
  --bg: #eff5f2;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-soft: #f6faf7;
  --text: #21302b;
  --muted: #65756f;
  --line: #d4e0da;
  --line-strong: #b8c9c0;
  --accent: #3c8064;
  --accent-dark: #2f684f;
  --accent-soft: #e7f3ed;
  --blue: #497c9d;
  --gold: #b38a42;
  --warn: #9a6500;
  --shadow: 0 18px 42px rgba(31, 54, 46, 0.12);
  --soft-shadow: 0 8px 20px rgba(31, 54, 46, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(60, 128, 100, 0.16), rgba(73, 124, 157, 0.08) 38%, rgba(179, 138, 66, 0.08)),
    repeating-linear-gradient(0deg, rgba(33, 48, 43, 0.032) 0, rgba(33, 48, 43, 0.032) 1px, transparent 1px, transparent 42px),
    repeating-linear-gradient(90deg, rgba(33, 48, 43, 0.024) 0, rgba(33, 48, 43, 0.024) 1px, transparent 1px, transparent 42px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 34px;
}

.topbar,
.toolbar-head,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 16px;
  min-height: 78px;
  padding: 15px 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 247, 0.9)),
    rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(212, 224, 218, 0.95);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(31, 54, 46, 0.1);
  backdrop-filter: blur(10px);
}

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

.bi-metric-help {
  position: relative;
  z-index: 60;
  display: inline-flex;
  margin-top: 8px;
}

.bi-metric-help-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 11px;
  color: var(--accent-dark);
  background: rgba(231, 243, 237, 0.7);
  border: 1px solid rgba(60, 128, 100, 0.22);
  border-radius: 999px;
  box-shadow: none;
  font-size: 13px;
  font-weight: 820;
  line-height: 1;
}

.bi-metric-help-trigger::after {
  content: "?";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.bi-metric-help-trigger:hover,
.bi-metric-help-trigger:focus {
  transform: none;
  color: var(--accent-dark);
  background: rgba(222, 241, 231, 0.98);
  border-color: rgba(60, 128, 100, 0.38);
  box-shadow: 0 6px 14px rgba(60, 128, 100, 0.1);
}

.bi-metric-help-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 80;
  width: min(640px, calc(100vw - 48px));
  padding: 15px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(174, 205, 190, 0.9);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(31, 54, 46, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
  visibility: hidden;
}

.bi-metric-help:hover .bi-metric-help-panel,
.bi-metric-help:focus-within .bi-metric-help-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.bi-metric-help-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 22px;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid rgba(174, 205, 190, 0.9);
  border-left: 1px solid rgba(174, 205, 190, 0.9);
  transform: rotate(45deg);
}

.bi-metric-help-panel strong,
.bi-metric-help-panel span {
  display: block;
}

.bi-metric-help-panel strong {
  color: var(--accent-dark);
  font-size: 14px;
  line-height: 1.45;
}

.bi-metric-help-panel ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.bi-metric-help-formulas {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(212, 224, 218, 0.9);
  color: var(--text);
  font-weight: 720;
  line-height: 1.5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 780;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  font-weight: 730;
}

.topbar p,
.toolbar-head p,
.status-value,
#totalCount {
  color: var(--muted);
}

.topbar p,
.toolbar-head p {
  margin-top: 4px;
}

.latest-return-date {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 24px;
  margin-top: 7px;
  padding: 0 9px;
  border: 1px solid rgba(60, 128, 100, 0.18);
  border-radius: 6px;
  background: rgba(231, 243, 237, 0.58);
  color: var(--accent-dark);
  font-weight: 700;
}

.latest-return-date span {
  font-variant-numeric: tabular-nums;
}

.bi-context-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.bi-context-line span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-left: 8px;
  padding: 3px 10px;
  border: 1px solid rgba(60, 128, 100, 0.22);
  border-radius: 999px;
  background: rgba(231, 243, 237, 0.78);
  color: var(--accent-dark);
  font-weight: 820;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
}

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

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--panel-solid);
  box-shadow: 0 6px 14px rgba(31, 54, 46, 0.06);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(60, 128, 100, 0.14);
}

.status-label,
.status-value {
  display: block;
  line-height: 1.35;
}

.status-label {
  color: var(--muted);
  font-size: 12px;
}

.status-value {
  font-weight: 700;
}

.portal-shell {
  display: grid;
  gap: 16px;
}

.portal-hero {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(212, 224, 218, 0.86);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.portal-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 88px;
  padding: 20px 22px;
}

.portal-title {
  min-width: 0;
}

.portal-kicker,
.category-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.portal-hero p,
.category-head p,
.app-card p,
.app-tags,
.category-empty,
.portal-nav-head {
  color: var(--muted);
}

.portal-overview {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex: 0 0 auto;
}

.overview-item {
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.overview-item span,
.overview-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.overview-item strong {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.portal-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.portal-section {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
}

.portal-section-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.portal-module-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.portal-module {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 190px;
  padding: 17px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(212, 224, 218, 0.88);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-section .portal-module {
  box-shadow: none;
}

.portal-module:hover {
  border-color: rgba(60, 128, 100, 0.26);
  background: rgba(250, 252, 251, 0.96);
}

.portal-module-bi {
  min-height: 190px;
  background: rgba(246, 250, 247, 0.9);
}

.portal-module-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.portal-module h2,
.portal-module h3,
.portal-module strong {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.portal-module h2,
.portal-module h3 {
  margin-top: 5px;
}

.portal-module p,
.portal-module small {
  color: var(--muted);
  line-height: 1.5;
}

.portal-module p {
  margin-top: 5px;
}

.portal-primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 124px;
  min-height: 38px;
  padding: 0 12px;
  color: #ffffff;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid rgba(47, 104, 79, 0.72);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(60, 128, 100, 0.18);
  font-weight: 820;
}

.portal-primary-link:hover {
  background: var(--accent-dark);
}

.portal-category-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 72px;
  margin-top: 8px;
  overflow: auto;
}

.portal-category-links a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--accent-dark);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(231, 243, 237, 0.72);
  border: 1px solid rgba(60, 128, 100, 0.18);
  border-radius: 999px;
  font-weight: 760;
}

.portal-category-links a:hover {
  border-color: rgba(60, 128, 100, 0.42);
  background: rgba(222, 241, 231, 0.96);
}

.portal-tool-accent {
  background: rgba(231, 243, 237, 0.64);
}

.portal-tool-muted {
  background: rgba(246, 250, 247, 0.52);
}

.portal-module strong,
.portal-module small {
  display: block;
}

.portal-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.portal-nav {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(212, 224, 218, 0.95);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-nav-head,
.portal-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-nav-head {
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.portal-nav-head strong {
  color: var(--accent-dark);
}

.portal-nav-item {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.portal-nav-item:hover,
.portal-nav-item.is-active {
  background: rgba(231, 243, 237, 0.72);
  border-color: rgba(60, 128, 100, 0.24);
  color: var(--accent-dark);
}

.portal-nav-item strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.portal-content {
  display: grid;
  gap: 18px;
}

.portal-category {
  padding: 18px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(212, 224, 218, 0.88);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.category-head h2 {
  margin: 0;
}

.category-count {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(73, 124, 157, 0.2);
  border-radius: 8px;
  background: rgba(232, 242, 248, 0.78);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.app-card {
  display: grid;
  gap: 14px;
  min-height: 210px;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.96), rgba(255, 255, 255, 0.84));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.app-card-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 247, 0.86)),
    linear-gradient(90deg, rgba(60, 128, 100, 0.1), rgba(73, 124, 157, 0.06));
}

.app-card-disabled {
  background: rgba(246, 250, 247, 0.58);
  border-style: dashed;
}

.app-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.app-card-disabled:hover {
  border-color: var(--line-strong);
  box-shadow: var(--soft-shadow);
  transform: none;
}

.app-card-link-panel:hover {
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
  transform: none;
}

.app-card-top,
.app-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-badge {
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid rgba(60, 128, 100, 0.2);
  border-radius: 6px;
  background: rgba(231, 243, 237, 0.72);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
}

.app-badge-muted {
  border-color: rgba(101, 117, 111, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.app-type {
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

.app-card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.app-card p {
  margin: 0;
  line-height: 1.6;
}

.app-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.app-tags span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
}

.app-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  align-self: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 800;
}

.app-card-links {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.app-card-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 10px;
  overflow: hidden;
  color: var(--accent-dark);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(60, 128, 100, 0.2);
  border-radius: 999px;
}

.app-card-links a:first-child {
  background: rgba(231, 243, 237, 0.82);
  font-weight: 850;
}

.app-card-links a:hover {
  border-color: rgba(60, 128, 100, 0.42);
  box-shadow: 0 4px 12px rgba(60, 128, 100, 0.1);
}

.category-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(246, 250, 247, 0.62);
}

.category-empty span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(231, 243, 237, 0.78);
  color: var(--accent-dark);
  font-weight: 800;
}

.category-empty p {
  margin: 0;
}

.toolbar,
.result {
  background: var(--panel);
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.toolbar {
  padding: 18px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.condition-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.94), rgba(255, 255, 255, 0.78));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(31, 54, 46, 0.045);
}

.condition-wide {
  grid-column: 1 / -1;
}

.condition-title {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field label,
.condition-card > label {
  font-weight: 680;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

input:focus,
textarea:focus,
.multi-toggle:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 128, 100, 0.16);
  background: #fff;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--panel-solid);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-color: transparent;
  color: #fff;
}

button.primary:hover {
  color: #fff;
}

button.report-button {
  background: linear-gradient(135deg, var(--gold), var(--accent));
  border-color: transparent;
  color: #fff;
}

button.report-button:hover {
  color: #fff;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.chips,
.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 31px;
}

.selected-chips {
  display: none;
  min-height: 0;
  align-content: flex-start;
  max-height: 74px;
  overflow: auto;
}

.selected-chips.has-values {
  display: flex;
}

.chips button,
.selected-chips button {
  min-height: 29px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--accent-soft);
  border-color: #c1d9cc;
  color: var(--accent-dark);
}

.empty-chip {
  color: var(--muted);
  padding: 6px 2px;
}

.multi-select {
  position: relative;
}

.multi-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.96);
}

.caret {
  color: var(--muted);
}

.multi-menu {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 7px);
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.multi-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.multi-tools button {
  min-height: 30px;
  padding: 0 10px;
}

.multi-options {
  max-height: 238px;
  overflow: auto;
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.multi-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 7px;
  border-radius: 6px;
}

.multi-option:hover {
  background: var(--panel-soft);
}

.multi-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.multi-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-empty {
  color: var(--muted);
  padding: 10px 6px;
}

.date-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.sales-date-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact input {
  height: 40px;
}

.result {
  margin-top: 18px;
  overflow: hidden;
}

.result-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.94), rgba(255, 255, 255, 0.74));
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

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

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #edf5ef;
  z-index: 1;
}

td {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr:hover td {
  background: rgba(231, 243, 237, 0.48);
}

.empty,
.error {
  padding: 16px;
}

.error {
  color: var(--warn);
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 1240px);
    margin: 12px auto 20px;
  }

  .topbar,
  .portal-hero,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-overview {
    flex-wrap: wrap;
  }

  .overview-item,
  .status-card {
    flex: 1 1 130px;
  }

  .portal-section-grid {
    grid-template-columns: 1fr;
  }

  .portal-module-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .portal-module-main {
    grid-template-columns: 1fr;
  }

  .portal-primary-link {
    width: 100%;
  }

  .portal-layout {
    grid-template-columns: 1fr;
  }

  .portal-nav {
    position: static;
  }

  .category-head {
    align-items: stretch;
    flex-direction: column;
  }

  .filters,
  .date-grid {
    grid-template-columns: 1fr;
  }
}

.bi-shell {
  display: grid;
  gap: 18px;
}

.bi-topbar {
  position: relative;
  z-index: 50;
  margin-bottom: 0;
}

.bi-download-panel,
.bi-filter-panel,
.bi-chart-panel {
  background: var(--panel);
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.bi-download-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
}

.bi-download-copy h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 820;
}

.bi-download-copy p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.55;
}

.bi-download-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.bi-download-buttons {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.bi-download-buttons button {
  min-height: 42px;
}

.bi-filter-panel {
  position: relative;
  z-index: 30;
  overflow: visible;
  padding: 0;
}

.bi-filter-panel .toolbar-head {
  min-height: 72px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
}

.bi-filter-panel .toolbar-head h2 {
  font-size: 24px;
  font-weight: 820;
}

.bi-filter-layout {
  display: grid;
  gap: 0;
  padding: 0 24px;
}

.bi-filter-row {
  display: grid;
  gap: 12px;
  align-items: start;
}

.bi-filter-row-primary {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.bi-filter-row-secondary,
.bi-filter-row-tertiary {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.bi-filter-row-lookup {
  grid-template-columns: minmax(220px, 0.82fr) minmax(220px, 0.82fr) minmax(360px, 1.36fr);
  margin-top: 16px;
  padding-bottom: 14px;
}

.bi-field {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 0;
}

.bi-select-field {
  position: relative;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(212, 224, 218, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.bi-flat-group {
  position: relative;
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
  padding: 18px 0;
  border-bottom: 1px solid rgba(212, 224, 218, 0.78);
}

.bi-field label {
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-date-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bi-date-field label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 780;
}

.bi-date-field input {
  min-height: 42px;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(184, 201, 192, 0.94);
}

.bi-select-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  text-align: left;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(184, 201, 192, 0.94);
}

.bi-select-toggle [data-summary] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bi-direct-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.bi-direct-entry input {
  min-height: 38px;
  padding: 8px 10px;
}

.bi-direct-entry button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-select-menu {
  position: absolute;
  z-index: 2000;
  top: var(--select-menu-top, calc(100% + 7px));
  right: 0;
  left: 0;
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bi-select-searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.bi-batch-toggle {
  min-height: 40px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-batch-toggle.is-active {
  background: var(--accent-soft);
  border-color: rgba(60, 128, 100, 0.44);
}

.bi-batch-box {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 9px;
  background: rgba(246, 250, 247, 0.9);
  border: 1px solid rgba(212, 224, 218, 0.92);
  border-radius: 8px;
}

.bi-batch-box[hidden] {
  display: none;
}

.bi-batch-box textarea {
  min-height: 88px;
  resize: vertical;
}

.bi-batch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bi-batch-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.bi-select-bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-top: 8px;
  padding: 6px 8px 6px 10px;
  background: rgba(242, 248, 245, 0.94);
  border: 1px solid rgba(198, 218, 208, 0.9);
  border-radius: 8px;
}

.bi-select-bulkbar[hidden] {
  display: none;
}

.bi-select-bulkbar [data-result-summary] {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.bi-select-bulk-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
}

.bi-select-bulk-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 760;
  background: rgba(255, 255, 255, 0.94);
}

.bi-select-bulk-actions [data-select-all] {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: rgba(60, 128, 100, 0.34);
}

.bi-select-bulk-actions button:disabled {
  cursor: default;
  opacity: 0.48;
}

.bi-select-options {
  display: grid;
  gap: 5px;
  max-height: 260px;
  margin-top: 8px;
  overflow: auto;
}

.bi-slicer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 7px 0 0;
}

.bi-slicer-head label {
  color: var(--text);
  font-size: 18px;
  font-weight: 820;
  line-height: 1.4;
}

.bi-slicer-head button {
  display: none;
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
}

.bi-flat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-height: 42px;
  max-height: 126px;
  overflow: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.bi-flat-options-inline,
.bi-filter-row-secondary .bi-flat-options-open {
  max-height: none;
  overflow: visible;
}

.bi-filter-row-tertiary .bi-flat-options-open {
  max-height: 118px;
  overflow: auto;
}

.bi-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  max-width: 100%;
  padding: 0 18px;
  overflow: hidden;
  color: #2f3a36;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 249, 0.96));
  border-color: rgba(212, 224, 218, 0.94);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(31, 54, 46, 0.06);
  font-weight: 720;
}

.bi-chip.is-selected {
  padding-right: 10px;
  background: linear-gradient(180deg, rgba(236, 249, 242, 0.98), rgba(228, 246, 236, 0.98));
  border-color: rgba(60, 128, 100, 0.28);
  color: #1e7a51;
  box-shadow: 0 6px 14px rgba(60, 128, 100, 0.12);
}

.bi-chip.is-selected::after {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 9px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.bi-chip.is-locked,
.bi-chip.is-locked:disabled {
  cursor: default;
  opacity: 1;
}

.bi-select-option {
  justify-content: flex-start;
  min-height: 34px;
  width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(212, 224, 218, 0.82);
}

.bi-select-option.is-selected {
  border-color: rgba(60, 128, 100, 0.4);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-empty {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.bi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.bi-kpi {
  min-width: 0;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 247, 0.86)),
    linear-gradient(90deg, rgba(60, 128, 100, 0.08), rgba(73, 124, 157, 0.05));
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.bi-kpi span,
.bi-kpi strong {
  display: block;
}

.bi-kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.bi-kpi strong {
  margin-top: 8px;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bi-chart-panel {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.bi-chart {
  width: 100%;
  height: 410px;
  min-height: 360px;
  background:
    repeating-linear-gradient(0deg, rgba(33, 48, 43, 0.025) 0, rgba(33, 48, 43, 0.025) 1px, transparent 1px, transparent 38px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 250, 247, 0.74));
}

.bi-metric-table-wrap {
  overflow-x: auto;
  margin-top: -1px;
  padding: 0 18px 18px;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.72), rgba(255, 255, 255, 0.92));
  border-top: 1px solid rgba(212, 224, 218, 0.9);
}

.bi-metric-table {
  width: 100%;
  min-width: max(980px, var(--period-table-width, 1170px));
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}

.bi-metric-table th,
.bi-metric-table td {
  min-width: 78px;
  padding: 10px 12px;
  border-right: 1px solid rgba(212, 224, 218, 0.8);
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
  text-align: right;
  white-space: nowrap;
}

.bi-metric-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf6f1;
  color: var(--accent-dark);
  font-weight: 800;
  text-align: right;
}

.bi-metric-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 138px;
  text-align: left;
  background: #f8fbf9;
  border-left: 1px solid rgba(212, 224, 218, 0.8);
}

.bi-metric-table thead th:first-child {
  z-index: 3;
  background: #e5f1eb;
}

.bi-metric-table tbody tr:nth-child(even) th,
.bi-metric-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.68);
}

.bi-table-empty {
  padding: 16px 0 18px;
  color: var(--muted);
}

.bi-result {
  margin-top: 0;
}

.bi-footer-actions {
  align-items: end;
  justify-content: flex-end;
  gap: 16px;
  margin: 0;
  padding: 16px 24px;
  border-top: 1px solid rgba(212, 224, 218, 0.82);
}

.bi-toolbar-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(168px, 218px));
  gap: 12px;
  flex: 1 1 450px;
}

.bi-action-buttons {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.bi-action-buttons button {
  min-height: 42px;
}

@media (max-width: 1040px) {
  .bi-control-grid,
  .bi-flat-board,
  .bi-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bi-filter-row-primary,
  .bi-filter-row-lookup {
    grid-template-columns: 1fr;
  }

  .bi-download-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .bi-download-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .bi-footer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .bi-action-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .portal-hero {
    padding: 16px;
  }

  .portal-overview {
    gap: 6px;
  }

  .overview-item,
  .status-card {
    flex-basis: calc(50% - 3px);
    min-width: 0;
  }

  .status-card {
    min-height: 52px;
  }

  .portal-section {
    padding: 14px;
  }

  .portal-section-head {
    min-height: 0;
  }

  .portal-module-list {
    grid-template-columns: 1fr;
  }

  .portal-module-bi {
    min-height: 220px;
  }

  .portal-module {
    min-height: 154px;
  }

  .portal-category-links a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .bi-control-grid,
  .bi-flat-board,
  .bi-kpi-grid {
    grid-template-columns: 1fr;
  }

  .bi-field-wide {
    grid-column: auto;
  }

  .bi-filter-row-primary,
  .bi-filter-row-secondary,
  .bi-filter-row-tertiary,
  .bi-filter-row-lookup {
    grid-template-columns: 1fr;
  }

  .bi-filter-panel .toolbar-head,
  .bi-download-panel,
  .bi-filter-layout,
  .bi-footer-actions {
    padding-right: 14px;
    padding-left: 14px;
  }

  .bi-flat-group {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .bi-slicer-head {
    margin-top: 0;
  }

  .bi-toolbar-dates {
    grid-template-columns: 1fr;
  }

  .bi-download-buttons {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .bi-chart {
    height: 420px;
  }

  .bi-kpi strong {
    font-size: 24px;
  }
}

/* codex-home-login */
.portal-logout {
  display: flex;
  align-items: stretch;
}

.portal-logout button {
  min-height: 100%;
  padding: 0 14px;
  color: var(--accent-dark);
  background: rgba(231, 243, 237, 0.7);
  border: 1px solid rgba(60, 128, 100, 0.25);
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.portal-logout button:hover,
.portal-logout button:focus-visible {
  background: var(--accent-soft);
  border-color: rgba(60, 128, 100, 0.48);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  width: min(920px, 100%);
  min-height: 540px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(212, 224, 218, 0.95);
  border-radius: 12px;
  box-shadow: 0 28px 72px rgba(31, 54, 46, 0.16);
  backdrop-filter: blur(14px);
}

.login-context {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 540px;
  padding: 52px 52px 48px 82px;
  background:
    linear-gradient(145deg, rgba(231, 243, 237, 0.98), rgba(239, 245, 242, 0.84)),
    repeating-linear-gradient(0deg, rgba(47, 104, 79, 0.08) 0, rgba(47, 104, 79, 0.08) 1px, transparent 1px, transparent 36px);
  border-right: 1px solid var(--line);
}

.login-access-mark {
  position: absolute;
  inset: 28px auto 28px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  color: rgba(47, 104, 79, 0.72);
  border-right: 1px solid rgba(60, 128, 100, 0.24);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1;
  writing-mode: vertical-rl;
}

.login-context h1 {
  max-width: 420px;
  margin: 0;
  color: var(--text);
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.login-context p {
  max-width: 390px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.login-signal {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 34px;
  padding: 9px 12px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(60, 128, 100, 0.18);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 54px 46px;
  background: rgba(255, 255, 255, 0.96);
}

.login-card-head > span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.login-card-head strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.2;
}

.login-card-head p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-error {
  margin-top: 22px;
  padding: 11px 12px;
  color: #8a3b2f;
  background: #fff1ed;
  border: 1px solid #efc7bc;
  border-radius: 8px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.login-form label {
  margin-top: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
  outline: none;
}

.login-form input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 128, 100, 0.14);
}

.login-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-top: 18px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent-dark);
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.login-submit:hover,
.login-submit:focus-visible {
  background: #285941;
  box-shadow: 0 10px 22px rgba(47, 104, 79, 0.22);
  transform: translateY(-1px);
}

.overview-item {
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.overview-item span,
.overview-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.overview-item strong {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.portal-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.portal-section {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
}

.portal-section-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.portal-module-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.portal-module {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 190px;
  padding: 17px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(212, 224, 218, 0.88);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-section .portal-module {
  box-shadow: none;
}

.portal-module:hover {
  border-color: rgba(60, 128, 100, 0.26);
  background: rgba(250, 252, 251, 0.96);
}

.portal-module-bi {
  min-height: 190px;
  background: rgba(246, 250, 247, 0.9);
}

.portal-module-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.portal-module h2,
.portal-module h3,
.portal-module strong {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.portal-module h2,
.portal-module h3 {
  margin-top: 5px;
}

.portal-module p,
.portal-module small {
  color: var(--muted);
  line-height: 1.5;
}

.portal-module p {
  margin-top: 5px;
}

.portal-primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 124px;
  min-height: 38px;
  padding: 0 12px;
  color: #ffffff;
  text-decoration: none;
  background: var(--accent);
  border: 1px solid rgba(47, 104, 79, 0.72);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(60, 128, 100, 0.18);
  font-weight: 820;
}

.portal-primary-link:hover {
  background: var(--accent-dark);
}

.portal-category-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 72px;
  margin-top: 8px;
  overflow: auto;
}

.portal-category-links a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--accent-dark);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(231, 243, 237, 0.72);
  border: 1px solid rgba(60, 128, 100, 0.18);
  border-radius: 999px;
  font-weight: 760;
}

.portal-category-links a:hover {
  border-color: rgba(60, 128, 100, 0.42);
  background: rgba(222, 241, 231, 0.96);
}

.portal-tool-accent {
  background: rgba(231, 243, 237, 0.64);
}

.portal-tool-muted {
  background: rgba(246, 250, 247, 0.52);
}

.portal-module strong,
.portal-module small {
  display: block;
}

.portal-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.portal-nav {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(212, 224, 218, 0.95);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.portal-nav-head,
.portal-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-nav-head {
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.portal-nav-head strong {
  color: var(--accent-dark);
}

.portal-nav-item {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.portal-nav-item:hover,
.portal-nav-item.is-active {
  background: rgba(231, 243, 237, 0.72);
  border-color: rgba(60, 128, 100, 0.24);
  color: var(--accent-dark);
}

.portal-nav-item strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.portal-content {
  display: grid;
  gap: 18px;
}

.portal-category {
  padding: 18px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(212, 224, 218, 0.88);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(8px);
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.category-head h2 {
  margin: 0;
}

.category-count {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(73, 124, 157, 0.2);
  border-radius: 8px;
  background: rgba(232, 242, 248, 0.78);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.app-card {
  display: grid;
  gap: 14px;
  min-height: 210px;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.96), rgba(255, 255, 255, 0.84));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.app-card-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 247, 0.86)),
    linear-gradient(90deg, rgba(60, 128, 100, 0.1), rgba(73, 124, 157, 0.06));
}

.app-card-disabled {
  background: rgba(246, 250, 247, 0.58);
  border-style: dashed;
}

.app-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.app-card-disabled:hover {
  border-color: var(--line-strong);
  box-shadow: var(--soft-shadow);
  transform: none;
}

.app-card-link-panel:hover {
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
  transform: none;
}

.app-card-top,
.app-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-badge {
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid rgba(60, 128, 100, 0.2);
  border-radius: 6px;
  background: rgba(231, 243, 237, 0.72);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
}

.app-badge-muted {
  border-color: rgba(101, 117, 111, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.app-type {
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

.app-card h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.app-card p {
  margin: 0;
  line-height: 1.6;
}

.app-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.app-tags span {
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
}

.app-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  align-self: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 800;
}

.app-card-links {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.app-card-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 10px;
  overflow: hidden;
  color: var(--accent-dark);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(60, 128, 100, 0.2);
  border-radius: 999px;
}

.app-card-links a:first-child {
  background: rgba(231, 243, 237, 0.82);
  font-weight: 850;
}

.app-card-links a:hover {
  border-color: rgba(60, 128, 100, 0.42);
  box-shadow: 0 4px 12px rgba(60, 128, 100, 0.1);
}

.category-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(246, 250, 247, 0.62);
}

.category-empty span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(231, 243, 237, 0.78);
  color: var(--accent-dark);
  font-weight: 800;
}

.category-empty p {
  margin: 0;
}

.toolbar,
.result {
  background: var(--panel);
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.toolbar {
  padding: 18px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.condition-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.94), rgba(255, 255, 255, 0.78));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(31, 54, 46, 0.045);
}

.condition-wide {
  grid-column: 1 / -1;
}

.condition-title {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field label,
.condition-card > label {
  font-weight: 680;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

input:focus,
textarea:focus,
.multi-toggle:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 128, 100, 0.16);
  background: #fff;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--panel-solid);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-color: transparent;
  color: #fff;
}

button.primary:hover {
  color: #fff;
}

button.report-button {
  background: linear-gradient(135deg, var(--gold), var(--accent));
  border-color: transparent;
  color: #fff;
}

button.report-button:hover {
  color: #fff;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.chips,
.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 31px;
}

.selected-chips {
  display: none;
  min-height: 0;
  align-content: flex-start;
  max-height: 74px;
  overflow: auto;
}

.selected-chips.has-values {
  display: flex;
}

.chips button,
.selected-chips button {
  min-height: 29px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--accent-soft);
  border-color: #c1d9cc;
  color: var(--accent-dark);
}

.empty-chip {
  color: var(--muted);
  padding: 6px 2px;
}

.multi-select {
  position: relative;
}

.multi-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.96);
}

.caret {
  color: var(--muted);
}

.multi-menu {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 7px);
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.multi-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.multi-tools button {
  min-height: 30px;
  padding: 0 10px;
}

.multi-options {
  max-height: 238px;
  overflow: auto;
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.multi-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 7px;
  border-radius: 6px;
}

.multi-option:hover {
  background: var(--panel-soft);
}

.multi-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.multi-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-empty {
  color: var(--muted);
  padding: 10px 6px;
}

.date-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.sales-date-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact input {
  height: 40px;
}

.result {
  margin-top: 18px;
  overflow: hidden;
}

.result-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.94), rgba(255, 255, 255, 0.74));
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

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

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #edf5ef;
  z-index: 1;
}

td {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr:hover td {
  background: rgba(231, 243, 237, 0.48);
}

.empty,
.error {
  padding: 16px;
}

.error {
  color: var(--warn);
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 1240px);
    margin: 12px auto 20px;
  }

  .topbar,
  .portal-hero,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-overview {
    flex-wrap: wrap;
  }

  .overview-item,
  .status-card {
    flex: 1 1 130px;
  }

  .portal-section-grid {
    grid-template-columns: 1fr;
  }

  .portal-module-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .portal-module-main {
    grid-template-columns: 1fr;
  }

  .portal-primary-link {
    width: 100%;
  }

  .portal-layout {
    grid-template-columns: 1fr;
  }

  .portal-nav {
    position: static;
  }

  .category-head {
    align-items: stretch;
    flex-direction: column;
  }

  .filters,
  .date-grid {
    grid-template-columns: 1fr;
  }
}

.bi-shell {
  display: grid;
  gap: 18px;
}

.bi-topbar {
  position: relative;
  z-index: 50;
  margin-bottom: 0;
}

.bi-download-panel,
.bi-filter-panel,
.bi-chart-panel {
  background: var(--panel);
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.bi-download-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
}

.bi-download-copy h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 820;
}

.bi-download-copy p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.55;
}

.bi-download-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.bi-download-buttons {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.bi-download-buttons button {
  min-height: 42px;
}

.bi-filter-panel {
  position: relative;
  z-index: 30;
  overflow: visible;
  padding: 0;
}

.bi-filter-panel .toolbar-head {
  min-height: 72px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
}

.bi-filter-panel .toolbar-head h2 {
  font-size: 24px;
  font-weight: 820;
}

.bi-filter-layout {
  display: grid;
  gap: 0;
  padding: 0 24px;
}

.bi-filter-row {
  display: grid;
  gap: 12px;
  align-items: start;
}

.bi-filter-row-primary {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.bi-filter-row-secondary,
.bi-filter-row-tertiary {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.bi-filter-row-lookup {
  grid-template-columns: minmax(220px, 0.82fr) minmax(220px, 0.82fr) minmax(360px, 1.36fr);
  margin-top: 16px;
  padding-bottom: 14px;
}

.bi-field {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 0;
}

.bi-select-field {
  position: relative;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(212, 224, 218, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.bi-flat-group {
  position: relative;
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
  padding: 18px 0;
  border-bottom: 1px solid rgba(212, 224, 218, 0.78);
}

.bi-field label {
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-date-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bi-date-field label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 780;
}

.bi-date-field input {
  min-height: 42px;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(184, 201, 192, 0.94);
}

.bi-select-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  text-align: left;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(184, 201, 192, 0.94);
}

.bi-select-toggle [data-summary] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bi-direct-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.bi-direct-entry input {
  min-height: 38px;
  padding: 8px 10px;
}

.bi-direct-entry button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-select-menu {
  position: absolute;
  z-index: 2000;
  top: var(--select-menu-top, calc(100% + 7px));
  right: 0;
  left: 0;
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bi-select-searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.bi-batch-toggle {
  min-height: 40px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-batch-toggle.is-active {
  background: var(--accent-soft);
  border-color: rgba(60, 128, 100, 0.44);
}

.bi-batch-box {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 9px;
  background: rgba(246, 250, 247, 0.9);
  border: 1px solid rgba(212, 224, 218, 0.92);
  border-radius: 8px;
}

.bi-batch-box[hidden] {
  display: none;
}

.bi-batch-box textarea {
  min-height: 88px;
  resize: vertical;
}

.bi-batch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bi-batch-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.bi-select-options {
  display: grid;
  gap: 5px;
  max-height: 260px;
  margin-top: 8px;
  overflow: auto;
}

.bi-slicer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 7px 0 0;
}

.bi-slicer-head label {
  color: var(--text);
  font-size: 18px;
  font-weight: 820;
  line-height: 1.4;
}

.bi-slicer-head button {
  display: none;
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
}

.bi-flat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-height: 42px;
  max-height: 126px;
  overflow: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.bi-flat-options-inline,
.bi-filter-row-secondary .bi-flat-options-open {
  max-height: none;
  overflow: visible;
}

.bi-filter-row-tertiary .bi-flat-options-open {
  max-height: 118px;
  overflow: auto;
}

.bi-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  max-width: 100%;
  padding: 0 18px;
  overflow: hidden;
  color: #2f3a36;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 249, 0.96));
  border-color: rgba(212, 224, 218, 0.94);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(31, 54, 46, 0.06);
  font-weight: 720;
}

.bi-chip.is-selected {
  padding-right: 10px;
  background: linear-gradient(180deg, rgba(236, 249, 242, 0.98), rgba(228, 246, 236, 0.98));
  border-color: rgba(60, 128, 100, 0.28);
  color: #1e7a51;
  box-shadow: 0 6px 14px rgba(60, 128, 100, 0.12);
}

.bi-chip.is-selected::after {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 9px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.bi-chip.is-locked,
.bi-chip.is-locked:disabled {
  cursor: default;
  opacity: 1;
}

.bi-select-option {
  justify-content: flex-start;
  min-height: 34px;
  width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(212, 224, 218, 0.82);
}

.bi-select-option.is-selected {
  border-color: rgba(60, 128, 100, 0.4);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 760;
}

.bi-empty {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.bi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.bi-kpi {
  min-width: 0;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 247, 0.86)),
    linear-gradient(90deg, rgba(60, 128, 100, 0.08), rgba(73, 124, 157, 0.05));
  border: 1px solid rgba(212, 224, 218, 0.96);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.bi-kpi span,
.bi-kpi strong {
  display: block;
}

.bi-kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.bi-kpi strong {
  margin-top: 8px;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bi-chart-panel {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.bi-chart {
  width: 100%;
  height: 410px;
  min-height: 360px;
  background:
    repeating-linear-gradient(0deg, rgba(33, 48, 43, 0.025) 0, rgba(33, 48, 43, 0.025) 1px, transparent 1px, transparent 38px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 250, 247, 0.74));
}

.bi-metric-table-wrap {
  overflow-x: auto;
  margin-top: -1px;
  padding: 0 18px 18px;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.72), rgba(255, 255, 255, 0.92));
  border-top: 1px solid rgba(212, 224, 218, 0.9);
}

.bi-metric-table {
  width: 100%;
  min-width: max(980px, var(--period-table-width, 1170px));
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}

.bi-metric-table th,
.bi-metric-table td {
  min-width: 78px;
  padding: 10px 12px;
  border-right: 1px solid rgba(212, 224, 218, 0.8);
  border-bottom: 1px solid rgba(212, 224, 218, 0.8);
  text-align: right;
  white-space: nowrap;
}

.bi-metric-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf6f1;
  color: var(--accent-dark);
  font-weight: 800;
  text-align: right;
}

.bi-metric-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 138px;
  text-align: left;
  background: #f8fbf9;
  border-left: 1px solid rgba(212, 224, 218, 0.8);
}

.bi-metric-table thead th:first-child {
  z-index: 3;
  background: #e5f1eb;
}

.bi-metric-table tbody tr:nth-child(even) th,
.bi-metric-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.68);
}

.bi-table-empty {
  padding: 16px 0 18px;
  color: var(--muted);
}

.bi-result {
  margin-top: 0;
}

.bi-footer-actions {
  align-items: end;
  justify-content: flex-end;
  gap: 16px;
  margin: 0;
  padding: 16px 24px;
  border-top: 1px solid rgba(212, 224, 218, 0.82);
}

.bi-toolbar-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(168px, 218px));
  gap: 12px;
  flex: 1 1 450px;
}

.bi-action-buttons {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.bi-action-buttons button {
  min-height: 42px;
}

@media (max-width: 1040px) {
  .bi-control-grid,
  .bi-flat-board,
  .bi-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bi-filter-row-primary,
  .bi-filter-row-lookup {
    grid-template-columns: 1fr;
  }

  .bi-download-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .bi-download-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .bi-footer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .bi-action-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .login-page {
    display: block;
    padding: 14px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-context {
    align-items: flex-end;
    min-height: 260px;
    padding: 38px 28px 32px 62px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .login-context h1 {
    font-size: 36px;
  }

  .login-signal {
    margin-top: 22px;
  }

  .login-card {
    padding: 34px 26px 38px;
  }
}

/* codex-product-risk-scatter */
.bi-risk-head {
  align-items: flex-start;
  gap: 18px;
}

.bi-risk-head > div {
  min-width: 0;
}

.bi-chart-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.bi-chart-summary {
  flex: 0 0 auto;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bi-risk-chart {
  height: 470px;
  min-height: 400px;
}

.bi-risk-details {
  border-top: 1px solid rgba(212, 224, 218, 0.9);
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.72), rgba(255, 255, 255, 0.92));
}

.bi-risk-details summary {
  min-height: 44px;
  padding: 13px 22px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.bi-risk-details summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.bi-risk-table-wrap {
  overflow-x: auto;
  padding: 0 18px 18px;
}

.bi-risk-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bi-risk-table caption {
  padding: 4px 0 10px;
  color: var(--muted);
  text-align: left;
}

.bi-risk-table th,
.bi-risk-table td {
  padding: 9px 11px;
  border: 1px solid rgba(212, 224, 218, 0.82);
  text-align: left;
  vertical-align: top;
}

.bi-risk-table th {
  background: #edf6f1;
  color: var(--accent-dark);
  font-weight: 800;
  white-space: nowrap;
}

.bi-risk-table td:nth-child(4),
.bi-risk-table td:nth-child(5),
.bi-risk-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .bi-risk-head {
    display: block;
  }

  .bi-chart-summary {
    margin-top: 8px;
  }

  .bi-risk-chart {
    height: 430px;
    min-height: 390px;
  }
}

/* codex-platform-category-detail */
.portal-detail-entry {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(212, 224, 218, 0.9);
}

.portal-detail-entry-head,
.portal-platform-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.portal-detail-entry-head h4,
.portal-platform-group-head h5 {
  margin: 0;
  color: var(--text);
}

.portal-detail-entry-head h4 {
  font-size: 15px;
}

.portal-detail-entry-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.portal-detail-entry-head > span,
.portal-platform-group-head > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.portal-platform-groups {
  display: grid;
  gap: 10px;
}

.portal-platform-group {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(60, 128, 100, 0.16);
  border-radius: 12px;
  background: rgba(248, 251, 249, 0.94);
}

.portal-platform-group-head h5 {
  font-size: 14px;
}

.portal-platform-group .portal-category-links {
  max-height: none;
  margin: 0;
  overflow: visible;
}

.portal-platform-group .portal-category-links a {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.portal-platform-group .portal-category-links a:hover {
  box-shadow: 0 5px 14px rgba(31, 91, 66, 0.1);
}

.portal-platform-group .portal-category-links a:focus-visible,
.bi-breadcrumb a:focus-visible {
  outline: 3px solid rgba(60, 128, 100, 0.34);
  outline-offset: 2px;
}

.portal-detail-empty {
  margin: 0;
  padding: 18px;
  border-radius: 10px;
  background: rgba(232, 240, 236, 0.7);
  color: var(--muted);
  text-align: center;
}

.bi-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: rgba(248, 251, 249, 0.96);
  color: var(--muted);
  font-size: 13px;
}

.bi-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.bi-breadcrumb a:hover {
  text-decoration: underline;
}

.bi-breadcrumb strong {
  color: var(--text);
}

.bi-detail-mode .bi-topbar {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.bi-context-locks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.bi-context-locks strong {
  color: var(--muted);
  font-size: 13px;
}

.bi-context-locks span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid rgba(60, 128, 100, 0.24);
  border-radius: 999px;
  background: #edf7f2;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 760;
}

.bi-category-grid.bi-category-grid-detail {
  grid-template-columns: minmax(0, 1fr);
}

.bi-detail-period-panel .bi-period-table-stack {
  margin-top: 0;
}

@media (max-width: 720px) {
  .portal-detail-entry-head {
    flex-direction: column;
  }

  .portal-platform-group .portal-category-links a {
    flex: 1 1 calc(50% - 7px);
  }

  .bi-breadcrumb {
    padding-inline: 12px;
  }
}


/* codex-category-risk */
.bi-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.bi-category-grid .bi-chart-panel {
  min-width: 0;
}

.bi-category-chart {
  height: 540px;
  min-height: 420px;
}

.bi-category-table {
  min-width: 760px;
}

.bi-category-table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.bi-category-table th[aria-sort] {
  color: var(--accent-dark);
}

@media (max-width: 1080px) {
  .bi-category-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .bi-category-chart {
    height: 520px;
    min-height: 420px;
  }
}

/* codex-platform-period-analysis */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bi-shell {
  grid-template-columns: minmax(0, 1fr);
}

.bi-period-panel {
  min-width: 0;
  overflow: hidden;
}

.bi-period-head {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px;
}

.bi-period-head > div {
  min-width: 0;
}

.bi-period-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: auto;
}

.bi-period-export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(60, 128, 100, 0.28);
  border-radius: 10px;
  background: #f4faf7;
  color: var(--accent-dark);
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

.bi-chart-expand-button,
.bi-chart-dialog-close {
  display: inline-grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(60, 128, 100, 0.28);
  border-radius: 10px;
  background: #f4faf7;
  color: var(--accent-dark);
  cursor: pointer;
}

.bi-chart-expand-button:hover,
.bi-period-export-button:hover,
.bi-chart-dialog-close:hover {
  border-color: var(--accent);
  background: #e8f4ee;
}

.bi-chart-expand-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.bi-period-export-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.bi-chart-expand-button:focus-visible,
.bi-period-export-button:focus-visible,
.bi-chart-dialog-close:focus-visible {
  outline: 3px solid rgba(60, 128, 100, 0.34);
  outline-offset: 2px;
}

.bi-chart-expand-button svg,
.bi-period-export-button svg,
.bi-chart-dialog-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.bi-period-heatmap {
  height: 390px;
  min-height: 330px;
}

.bi-period-table-stack {
  display: grid;
  gap: 18px;
  margin: 18px;
}

.bi-period-table-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(212, 224, 218, 0.9);
  border-radius: 14px;
  background: #fff;
}

.bi-period-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.9);
  background: #f8fbf9;
}

.bi-period-table-head > div {
  min-width: 0;
}

.bi-period-table-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.bi-period-table-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.bi-period-table-wrap {
  max-height: 620px;
  overflow: auto;
}

.bi-period-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bi-period-table th,
.bi-period-table td {
  padding: 10px 11px;
  border-right: 1px solid rgba(212, 224, 218, 0.82);
  border-bottom: 1px solid rgba(212, 224, 218, 0.82);
  text-align: right;
  white-space: nowrap;
}

.bi-period-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #e5f1eb;
  color: var(--accent-dark);
  font-weight: 800;
}

.bi-period-table th:first-child,
.bi-period-table td:first-child {
  position: sticky;
  left: 0;
  min-width: 96px;
  text-align: left;
}

.bi-period-table th:nth-child(2),
.bi-period-table td:nth-child(2) {
  position: sticky;
  left: 118px;
  min-width: 210px;
  text-align: left;
}

.bi-period-table th:first-child,
.bi-period-table th:nth-child(2) {
  z-index: 7;
}

.bi-period-month-row td {
  background: #eaf3ff;
  color: #243b53;
  font-weight: 700;
}

.bi-period-month-row:hover td {
  background: #dcecff;
}

.bi-period-week-row td {
  background: #f2f8f4;
  color: #334e3d;
}

.bi-period-total-row td {
  background: #e7eeea;
  color: #21302b;
  font-weight: 800;
}

.bi-period-table .bi-period-rate-alert {
  background: #f8c8cc;
  color: #7a1d25;
  font-weight: 800;
}

.bi-period-empty {
  padding: 42px 22px;
  color: var(--muted);
  text-align: center;
}

.bi-chart-dialog {
  width: min(94vw, 1500px);
  max-width: none;
  height: min(88vh, 940px);
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(60, 128, 100, 0.28);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(20, 45, 35, 0.28);
}

.bi-chart-dialog::backdrop {
  background: rgba(18, 35, 29, 0.62);
  backdrop-filter: blur(3px);
}

.bi-chart-dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.bi-chart-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(212, 224, 218, 0.9);
}

.bi-chart-dialog-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

.bi-chart-dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.bi-period-heatmap-large {
  width: 100%;
  height: 100%;
  min-height: 520px;
}

@media (max-width: 720px) {
  .bi-toolbar-dates {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .bi-period-head {
    display: flex;
  }

  .bi-period-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .bi-period-table-stack {
    margin: 12px;
  }

  .bi-period-table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .bi-period-table-head .bi-period-export-button {
    align-self: stretch;
  }

  .bi-period-heatmap {
    height: 360px;
    min-height: 320px;
  }

  .bi-chart-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    border-radius: 12px;
  }

  .bi-chart-dialog-head {
    padding: 14px;
  }

  .bi-period-heatmap-large {
    min-height: 440px;
  }

  .bi-select-bulkbar {
    align-items: stretch;
    flex-direction: column;
  }

  .bi-select-bulk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .bi-select-bulk-actions button {
    min-height: 44px;
  }
}
