:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1e2528;
  --muted: #687277;
  --line: #dce3e7;
  --nav: #071a44;
  --nav-deep: #041235;
  --nav-soft: rgba(255, 255, 255, 0.08);
  --nav-muted: #b8c5df;
  --nav-active: #1d6fd6;
  --nav-active-soft: rgba(29, 111, 214, 0.18);
  --teal: #177b73;
  --blue: #315f9b;
  --amber: #b4741e;
  --rose: #b94b5f;
  --green-soft: #e7f4f1;
  --blue-soft: #e8eef8;
  --amber-soft: #fff2dc;
  --rose-soft: #fae8eb;
  --shadow: 0 18px 45px rgba(37, 48, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", "Geist", "Satoshi", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dashboard-mode {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

body.dashboard-mode .app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 0;
  background:
    linear-gradient(180deg, rgba(19, 78, 160, 0.28), transparent 220px),
    var(--nav);
  color: #fff;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.dashboard-mode .sidebar {
  min-height: 0;
  overflow: auto;
}

.brand-mark {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 2px 8px 14px;
}

.brand-mark h1 {
  color: #fff;
}

.brand-mark p {
  color: var(--nav-muted);
}

.hidden {
  display: none !important;
}

body.auth-pending {
  min-height: 100dvh;
  overflow: hidden;
}

.auth-shell {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(7, 26, 68, 0.96), rgba(8, 42, 84, 0.92)),
    #071a44;
  color: #f7fbff;
}

.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-bg::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}

.auth-beam {
  position: absolute;
  left: 50%;
  width: min(920px, 84vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(154, 203, 255, 0.08), rgba(154, 203, 255, 0.72), rgba(154, 203, 255, 0.08), transparent);
  opacity: 0.5;
  transform: translateX(-50%) rotate(var(--auth-beam-rotate));
  transform-origin: 50% 50%;
}

.auth-beam::after {
  content: "";
  position: absolute;
  inset: -20px 0;
  background: linear-gradient(90deg, transparent, rgba(154, 203, 255, 0.12), transparent);
  opacity: 0.62;
}

.auth-beam-one {
  --auth-beam-rotate: -12deg;
  top: 22%;
}

.auth-beam-two {
  --auth-beam-rotate: 16deg;
  bottom: 18%;
  background: linear-gradient(90deg, transparent, rgba(127, 221, 209, 0.08), rgba(127, 221, 209, 0.56), rgba(127, 221, 209, 0.08), transparent);
}

.auth-grid {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.72fr);
  gap: 56px;
  align-items: center;
  padding: 42px 0;
}

.auth-copy {
  max-width: 660px;
}

.auth-kicker {
  margin: 0 0 18px;
  color: #9cc7ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-copy h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(42px, 6.4vw, 82px);
  line-height: 0.98;
  letter-spacing: 0;
  max-width: 10ch;
}

.auth-lede {
  margin: 22px 0 0;
  max-width: 540px;
  color: #c5d2e4;
  font-size: 17px;
  line-height: 1.65;
}

.auth-signal-board {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.auth-signal-board div {
  min-height: 102px;
  padding: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-signal-board div:last-child {
  border-right: 0;
}

.auth-signal-board span {
  display: block;
  color: #9fb0c7;
  font-size: 12px;
  font-weight: 750;
}

.auth-signal-board strong {
  display: block;
  margin-top: 18px;
  color: #ffffff;
  font-size: 15px;
}

.auth-panel {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 253, 0.96)),
    #ffffff;
  color: #132027;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
  padding: 26px;
}

.auth-panel-header {
  margin-bottom: 24px;
}

.auth-panel-header p {
  margin: 0 0 7px;
  color: #315f9b;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-panel-header h2 {
  margin: 0;
  color: #14202a;
  font-size: 30px;
  line-height: 1.08;
}

.auth-field {
  display: grid;
  gap: 8px;
  margin-bottom: 17px;
  color: #26333a;
  font-size: 13px;
  font-weight: 750;
}

.auth-field input {
  width: 100%;
  height: 48px;
  border: 1px solid #c9d4dc;
  border-radius: 6px;
  background: #f9fbfc;
  color: #132027;
  padding: 0 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.auth-field input:focus {
  border-color: #315f9b;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(49, 95, 155, 0.18);
}

.auth-submit {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 6px;
  background: #123a73;
  color: #ffffff;
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.auth-submit:hover {
  background: #0d3267;
}

.auth-submit:active {
  transform: translateY(1px) scale(0.99);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.auth-status {
  min-height: 20px;
  margin: 14px 0 0;
  color: #687277;
  font-size: 13px;
  line-height: 1.45;
}

.auth-status[data-tone="error"] {
  color: #a53647;
}

.auth-status[data-tone="muted"] {
  color: #315f9b;
}

.auth-logout {
  margin-top: -12px;
}

body:not(.auth-ready) .auth-copy,
body:not(.auth-ready) .auth-panel {
  opacity: 0;
  transform: translateY(14px);
}

body.auth-ready .auth-copy,
body.auth-ready .auth-panel {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 520ms ease, transform 520ms ease;
}

@media (prefers-reduced-motion: no-preference) {
  body.auth-ready .auth-beam-one {
    animation: authBeamDrift 14s ease-in-out infinite alternate;
  }

  body.auth-ready .auth-beam-two {
    animation: authBeamDrift 18s ease-in-out infinite alternate-reverse;
  }
}

@keyframes authBeamDrift {
  from {
    transform: translateX(-50%) translate3d(-18px, 0, 0) rotate(var(--auth-beam-rotate));
  }

  to {
    transform: translateX(-50%) translate3d(18px, 0, 0) rotate(var(--auth-beam-rotate));
  }
}

@media (max-width: 860px) {
  body.auth-pending {
    overflow: auto;
  }

  .auth-grid {
    width: min(100% - 28px, 520px);
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    align-items: start;
    padding: 30px 0;
  }

  .auth-copy h1 {
    max-width: 11ch;
    font-size: clamp(36px, 12vw, 56px);
  }

  .auth-lede {
    font-size: 15px;
    line-height: 1.55;
  }

  .auth-signal-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-signal-board div {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .auth-signal-board div:last-child {
    border-bottom: 0;
  }

  .auth-panel {
    padding: 22px;
  }
}

.language-toggle {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  padding: 0 10px;
}

.language-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.page-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.page-nav-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #ecf4ff;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  opacity: 0.94;
}

.nav-icon svg,
.nav-chevron svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  margin-left: auto;
  color: var(--nav-muted);
  transition: transform 160ms ease, color 160ms ease;
}

.page-nav-button.active {
  background: linear-gradient(90deg, var(--nav-active), rgba(29, 111, 214, 0.58));
  border-color: transparent;
  color: #fff;
}

.page-nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.page-nav-button.active:hover {
  background: linear-gradient(90deg, var(--nav-active), rgba(29, 111, 214, 0.58));
}

.page-nav-button.wide {
  grid-column: auto;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.report-nav {
  justify-content: flex-start;
}

.report-nav[aria-expanded="true"] .nav-chevron {
  color: #dbeaff;
  transform: rotate(180deg);
}

.nav-subnav {
  display: grid;
  gap: 3px;
  margin-left: 17px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.nav-subnav.collapsed {
  display: none;
}

.nav-subnav .page-nav-button {
  min-height: 29px;
  border-radius: 5px;
  color: var(--nav-muted);
  font-size: 12px;
  padding: 5px 8px;
}

.nav-subnav .nav-icon {
  width: 13px;
  height: 13px;
}

.nav-subnav .page-nav-button.active {
  color: #fff;
  background: var(--nav-active-soft);
  box-shadow: inset 3px 0 0 var(--nav-active);
}

.mark-grid {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background:
    linear-gradient(90deg, transparent 47%, rgba(255, 255, 255, 0.55) 48%, rgba(255, 255, 255, 0.55) 52%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(255, 255, 255, 0.55) 48%, rgba(255, 255, 255, 0.55) 52%, transparent 53%),
    linear-gradient(135deg, #1d6fd6, #16a3cc);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 16px;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
}

p {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.sidebar .panel {
  background: var(--nav-soft);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 11px;
  border-radius: 7px;
}

.sidebar .panel-title {
  color: #fff;
  margin-bottom: 8px;
}

.panel-title,
.chart-header,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  justify-content: flex-start;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 13px;
}

.panel-title svg,
.chart-header svg,
.chat-input svg,
.secondary-button svg,
.icon-button svg {
  width: 17px;
  height: 17px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
}

.source-row:first-of-type {
  border-top: 0;
}

.source-row span {
  color: var(--nav-muted);
}

.source-row strong {
  color: #79e0c9;
  font-size: 12px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.dashboard-filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.dashboard-filters .panel-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filters select,
.filters input,
.chat-input input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.filters select,
.filters input {
  min-height: 34px;
  padding: 6px 9px;
}

.filters select:focus,
.filters input:focus,
.chat-input input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 123, 115, 0.13);
}

.chat-input input:focus {
  border-color: var(--nav-active);
  box-shadow: 0 0 0 3px rgba(29, 111, 214, 0.14);
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  color: var(--ink) !important;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.secondary-button,
.icon-button,
.sort-button,
.quick-actions button,
.chat-input button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.secondary-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.workspace {
  position: relative;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

body.dashboard-mode .workspace {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.tier-scroll-mode {
  overflow: hidden;
}

body.tier-scroll-mode .app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.tier-scroll-mode .sidebar {
  min-height: 0;
  overflow-y: auto;
}

body.tier-scroll-mode .workspace {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

body.tier-scroll-mode .tier-page {
  align-content: start;
  padding-bottom: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

body.dashboard-mode .topbar.dashboard-page {
  flex: 0 0 auto;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.quick-actions button:hover,
.secondary-button:hover,
.sort-button:hover,
.icon-button:hover,
.chat-input button:hover {
  border-color: #b8c4ca;
  background: #f8fafb;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 22px rgba(37, 48, 56, 0.04);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
}

.payment-status-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.payment-status-pill {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 8px 22px rgba(37, 48, 56, 0.04);
}

.payment-status-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.payment-status-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.96fr) minmax(0, 1.04fr);
  gap: 14px;
  align-items: stretch;
  min-height: clamp(620px, calc(100vh - 150px), 820px);
}

body.dashboard-mode .main-grid.dashboard-page {
  flex: 1 1 auto;
  grid-auto-rows: minmax(0, 1fr);
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.chat-panel,
.insight-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chat-panel {
  min-height: clamp(620px, calc(100vh - 150px), 820px);
  display: grid;
  grid-template-rows: 1fr auto;
}

body.dashboard-mode .chat-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-log {
  padding: 14px;
  overflow: auto;
  max-height: none;
  min-height: 0;
}

.message {
  max-width: 92%;
  margin: 0 0 10px;
  padding: 10px 11px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
}

.message.assistant {
  background: #eef6ff;
  border: 1px solid #c9ddf6;
  color: var(--ink);
}

.message.user {
  margin-left: auto;
  background: var(--blue-soft);
  border: 1px solid #cbd8ee;
}

.message strong {
  font-weight: 800;
}

.message p {
  margin-top: 8px;
  color: var(--ink);
  font-size: 12px;
}

.message.assistant > p {
  color: var(--ink);
}

.message.assistant .recommendation-answer,
.message.assistant .result-table-wrap,
.message.assistant .download-card {
  color: var(--ink);
}

.message.assistant .recommendation-answer,
.message.assistant .result-table-wrap {
  border-color: rgba(29, 111, 214, 0.2);
}

.merchant-card {
  display: grid;
  gap: 8px;
}

.merchant-card h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
}

.db-chat-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(36, 104, 242, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 248, 255, 0.92));
  padding: 10px;
}

.db-chat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.db-chat-card-head span {
  color: #607086;
  font-size: 11px;
  font-weight: 850;
  text-align: right;
}

.db-chat-facts {
  display: grid;
  gap: 5px;
}

.db-chat-facts span,
.db-chat-products small {
  color: #52657f;
  font-size: 11px;
  font-weight: 800;
}

.db-chat-products {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
}

.db-chat-products li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(36, 104, 242, 0.1);
  padding-top: 7px;
}

.db-chat-products span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-chat-card-muted {
  border-color: rgba(96, 112, 134, 0.18);
  background: #f8fafc;
}

.merchant-card ul,
.recommendation-answer ul {
  margin: 0;
  padding-left: 18px;
}

.merchant-card li,
.recommendation-answer li {
  margin: 4px 0;
}

.result-table-wrap {
  margin-top: 8px;
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(23, 123, 115, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.result-table {
  min-width: 760px;
}

.result-table th,
.result-table td {
  padding: 8px 9px;
  background: transparent;
}

.result-table th {
  background: rgba(255, 255, 255, 0.72);
}

.result-table small {
  color: var(--muted);
  font-size: 11px;
}

/* ── Analysis tables in chatbot ────────────────────────────────────────── */

.analysis-section {
  margin-bottom: 16px;
  max-width: 100%;
  overflow-x: auto;
}

.analysis-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.analysis-table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 8px;
  border: 1px solid rgba(23, 123, 115, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
}

.analysis-table th,
.analysis-table td {
  padding: 7px 10px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.analysis-table th {
  background: rgba(255, 255, 255, 0.72);
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.analysis-table td {
  font-variant-numeric: tabular-nums;
}

.analysis-narrative {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(23, 123, 115, 0.06);
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}

.analysis-narrative p {
  margin: 0 0 8px 0;
}

.analysis-narrative p:last-child {
  margin-bottom: 0;
}

.analysis-narrative-placeholder {
  margin-top: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.tier-move-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 168px;
}

.tier-move-control select {
  height: 30px;
  min-width: 86px;
  padding: 0 26px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background-color: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.tier-move-button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tier-move-button:hover {
  background: var(--blue-dark);
}

.tier-override-note {
  margin-top: 5px;
  color: var(--green-strong);
  font-size: 11px;
  font-weight: 800;
}

.recommendation-answer {
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(23, 123, 115, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.download-card {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(29, 111, 214, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.download-card div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.download-card span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.download-xlsx-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: var(--nav-active);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

.chat-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-input input {
  min-height: 40px;
  padding: 9px 11px;
}

.chat-input button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.chat-input button {
  background: var(--nav-active);
  border-color: var(--nav-active);
  color: #fff;
}

.chat-input button:hover {
  background: #155ab9;
  border-color: #155ab9;
  color: #fff;
}

.insight-panel {
  align-self: stretch;
  display: grid;
  gap: 10px;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: none;
  min-height: clamp(620px, calc(100vh - 150px), 820px);
  overflow: hidden;
  padding: 14px;
}

body.dashboard-mode .insight-panel {
  height: 100%;
  min-height: 0;
}

.chart-header {
  margin-bottom: 10px;
}

.icon-button {
  min-width: 52px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.table-download-button {
  min-height: 34px;
  min-width: 92px;
}

.table-select-button {
  min-height: 34px;
  min-width: 78px;
}

.table-toolbar-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tier-pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.tier-pagination .secondary-button {
  min-height: 30px;
  min-width: 82px;
  padding: 5px 10px;
}

.tier-pagination .secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

#tierPageIndicator {
  min-width: 96px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.column-picker {
  position: relative;
}

.column-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 6;
  width: min(520px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

.column-picker-header {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.column-picker-header strong {
  font-size: 13px;
}

.column-picker-header span {
  color: var(--muted);
  font-size: 12px;
}

.column-picker-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.column-picker-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.column-picker-actions button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.column-picker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 300px;
  overflow: auto;
}

.column-check {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
}

.column-check input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.column-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recommendation-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context-panel {
  max-height: none;
  min-height: 0;
  overscroll-behavior: contain;
  overflow: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.context-panel > * {
  flex-shrink: 0;
}

.context-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.context-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 9px;
  min-width: 0;
}

.context-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.context-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.context-note,
.insight-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.insight-list {
  display: grid;
  gap: 5px;
}

.insight-list p {
  color: var(--ink);
  font-size: 12px;
}

.mini-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-table {
  min-width: 780px;
}

.mini-table th,
.mini-table td {
  padding: 8px 9px;
  font-size: 11px;
}

.mini-table small {
  color: var(--muted);
}

.merchant-focus {
  display: grid;
  gap: 8px;
}

.merchant-focus h4 {
  margin: 0;
  font-size: 15px;
}

.rec-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.rec-item .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.rec-item small {
  color: var(--muted);
}

.table-panel {
  overflow: hidden;
}

.category-group-row td {
  background: #f5f7f3;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.category-group-summary {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.category-group-summary strong {
  color: var(--ink);
  display: block;
  font-size: 14px;
}

.category-group-summary span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.category-group-summary dl {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  margin: 0;
  min-width: min(520px, 100%);
}

.category-group-summary div {
  min-width: 0;
}

.category-group-summary dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.category-group-summary dd {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}

.payments-page {
  display: grid;
  gap: 14px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: calc(100vh - 36px);
  height: calc(100dvh - 36px);
  min-height: 0;
  overflow: hidden;
}

.payments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.payment-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.payment-filter-search {
  grid-column: span 2;
}

.payment-filters label,
.tier-sheet-filters label,
.sheet-target-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.payment-filters select,
.payment-filters input[type="search"],
.tier-sheet-filters select,
.tier-sheet-filters input,
.sheet-target-filters select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 6px 9px;
}

.payment-filters select,
.payment-filters input[type="search"] {
  min-height: 38px;
  padding: 8px 10px;
}

.payment-filters select:focus,
.payment-filters input[type="search"]:focus,
.tier-sheet-filters select:focus,
.tier-sheet-filters input:focus,
.sheet-target-filters select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 123, 115, 0.13);
}

.payment-layout {
  display: grid;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.payment-table-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.table-wrap.payment-table-wrap {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.payment-table {
  min-width: 1500px;
}

.payment-table tbody tr {
  cursor: default;
}

.tier-page,
.sheet-page,
.category-page {
  display: grid;
  gap: 14px;
}

.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tier-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.tier-sheet-filters,
.sheet-target-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(330px, 1.8fr) repeat(4, minmax(100px, 1fr));
  gap: 10px;
  align-items: end;
}

.tier-date-range-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tier-date-range-controls {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto minmax(112px, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.tier-date-range-separator {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.tier-sheet-filters .tier-date-apply {
  min-height: 34px;
  padding: 6px 12px;
  white-space: nowrap;
}

.tier-date-status {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
}

.tier-date-status.error {
  color: var(--rose);
}

.tier-date-status.loading {
  color: var(--teal);
}

.sheet-target-filters {
  grid-template-columns: repeat(2, minmax(160px, 240px));
}

.sheet-page-header {
  align-items: flex-end;
}

.sheet-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-width: 240px;
}

.sheet-picker select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 6px 9px;
}

.sheet-picker select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 123, 115, 0.13);
}

.sheet-notes,
.sheet-target-notes {
  overflow: auto;
}

.sheet-page {
  --target-blue: #2468f2;
  --target-ink: #17233c;
  --target-soft: #f7faf8;
  --target-green: #16a064;
  --target-violet: #6a4df4;
  --target-amber: #d9871f;
  --target-shadow: 0 22px 70px rgba(28, 42, 66, 0.09);
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  align-items: start;
  gap: 16px;
  padding: 4px;
}

.sheet-page-header {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  min-height: 54px;
}

.sheet-page-header h2 {
  color: var(--target-ink);
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 850;
  line-height: 1.04;
  text-wrap: balance;
}

.sheet-page-header p {
  margin-top: 6px;
  color: #607086;
  font-size: 13px;
}

.sheet-page .sheet-target-filters {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: repeat(3, minmax(150px, 230px));
  justify-content: end;
  align-self: center;
  width: 100%;
  margin-left: 0;
  max-width: none;
  border-color: rgba(36, 104, 242, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 253, 0.94)),
    var(--panel);
  box-shadow: 0 16px 40px rgba(27, 54, 90, 0.08);
}

.sheet-page .sheet-target-filters label span {
  color: #465979;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.sheet-page .sheet-target-filters select {
  border-color: #d9e4f4;
  background-color: #fbfdff;
  color: var(--target-ink);
  font-weight: 800;
}

.sheet-page .tier-summary {
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
}

.sheet-page .sheet-target-notes {
  grid-column: 1 / -1;
}

.target-kpi-card,
.target-progress-card,
.target-report-card,
.sheet-page .tier-table-panel {
  border: 1px solid rgba(29, 56, 96, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 253, 0.94)),
    var(--panel);
  border-radius: 8px;
  box-shadow: var(--target-shadow);
}

.target-kpi-card {
  position: relative;
  min-height: 116px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  overflow: hidden;
  padding: 18px;
}

.target-kpi-card > div {
  min-width: 0;
}

.target-kpi-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.target-kpi-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 850;
}

.target-kpi-icon.blue {
  background: #e8f0ff;
  color: #2468f2;
}

.target-kpi-icon.green {
  background: #e4f7ed;
  color: #16a064;
}

.target-kpi-icon.amber {
  background: #fff1dd;
  color: #d9871f;
}

.target-kpi-icon.violet {
  background: #eee8ff;
  color: #6a4df4;
}

.target-kpi-icon.slate {
  background: #e9eef8;
  color: #375177;
}

.target-kpi-card span,
.target-progress-values span {
  color: #65758f;
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.target-kpi-card strong {
  display: block;
  margin: 6px 0;
  color: var(--target-ink);
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.target-delta,
.target-matrix-delta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 22px;
  color: #65758f;
  font-size: 11px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.target-delta.up,
.target-matrix-delta.up,
.target-progress-card .positive {
  color: var(--target-green);
}

.target-delta.down,
.target-matrix-delta.down,
.target-progress-card .negative {
  color: #d94d5c;
}

.sheet-target-notes {
  display: grid;
  gap: 16px;
  overflow: visible;
}

.target-progress-section {
  display: grid;
  gap: 12px;
}

.target-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.target-section-header h3 {
  color: var(--target-ink);
  font-size: 16px;
  font-weight: 850;
}

.target-section-header p {
  margin-top: 4px;
  color: #607086;
}

.target-section-header > span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(22, 160, 100, 0.22);
  border-radius: 7px;
  background: #ebf8f1;
  color: #138555;
  font-size: 11px;
  font-weight: 850;
  padding: 0 10px;
}

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

.target-progress-card {
  display: grid;
  gap: 12px;
  min-height: 168px;
  padding: 16px;
  transition: transform 540ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 540ms cubic-bezier(0.32, 0.72, 0, 1);
}

.target-progress-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 80px rgba(28, 42, 66, 0.13);
}

.target-progress-card-head,
.target-progress-values {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.target-progress-card-head strong {
  display: block;
  color: var(--target-ink);
  font-size: 15px;
  font-weight: 850;
}

.target-progress-card-head span:not(.target-status-pill) {
  color: #607086;
  font-size: 11px;
  font-weight: 800;
}

.target-status-pill {
  align-self: start;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 850;
  padding: 0 9px;
}

.target-status-pill.met {
  background: #e7f6ef;
  color: #128151;
}

.target-status-pill.miss {
  background: #fff0e1;
  color: #b46b16;
}

.target-status-pill.placeholder {
  border: 1px solid rgba(91, 110, 139, 0.18);
  background: #f2f5f9;
  color: #5b6e8b;
}

.target-progress-placeholder {
  border-style: dashed;
  background:
    linear-gradient(135deg, rgba(246, 249, 253, 0.98), rgba(255, 255, 255, 0.98)),
    var(--panel);
}

.target-progress-placeholder .target-placeholder-value {
  color: var(--target-blue);
}

.target-progress-bar.placeholder {
  background: repeating-linear-gradient(
    90deg,
    #e7edf5 0,
    #e7edf5 8px,
    #f7f9fc 8px,
    #f7f9fc 14px
  );
}

.target-progress-bar.placeholder span {
  width: 0;
  animation: none;
}

.target-progress-values strong {
  display: block;
  margin-top: 5px;
  color: var(--target-ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.target-value-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.target-value-line strong {
  margin-top: 0;
}

.target-edit-button,
.target-edit-form button {
  min-height: 26px;
  border: 1px solid rgba(36, 104, 242, 0.18);
  border-radius: 7px;
  background: #eef4ff;
  color: var(--target-blue);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  padding: 0 9px;
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1), background 260ms cubic-bezier(0.32, 0.72, 0, 1), border-color 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.target-edit-button:hover,
.target-edit-form button:hover {
  background: #e1ecff;
  border-color: rgba(36, 104, 242, 0.32);
  transform: translateY(-1px);
}

.target-edit-button:active,
.target-edit-form button:active,
.target-metric-tab:active {
  transform: scale(0.98);
}

.target-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  margin-top: 6px;
}

.target-edit-form input {
  min-height: 30px;
  min-width: 0;
  border: 1px solid #c9d9f2;
  border-radius: 7px;
  background: #fbfdff;
  color: var(--target-ink);
  font-size: 12px;
  font-weight: 750;
  outline: 0;
  padding: 5px 8px;
}

.target-edit-form input:focus {
  border-color: var(--target-blue);
  box-shadow: 0 0 0 3px rgba(36, 104, 242, 0.13);
}

.target-edit-form button[data-target-edit-cancel] {
  background: #f6f8fb;
  border-color: #dbe4f0;
  color: #607086;
}

.target-progress-values div:last-child {
  text-align: right;
}

.target-progress-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf1;
}

.target-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a064, #2468f2);
  transform-origin: left center;
  animation: targetBarFill 760ms cubic-bezier(0.32, 0.72, 0, 1) both;
  will-change: transform;
}

.target-progress-card p {
  color: #607086;
  font-size: 12px;
  font-weight: 850;
}

.target-report-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 250, 253, 0.97)),
    var(--panel);
}

.target-trend-card {
  min-height: 260px;
}

.target-trend-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.target-trend-view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid #dce6f4;
  border-radius: 8px;
  background: #fff;
  padding: 3px;
}

.target-trend-view-tab {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52657f;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  padding: 0 12px;
  transition: background 240ms ease, color 240ms ease, box-shadow 240ms ease;
}

.target-trend-view-tab:hover {
  color: var(--target-blue);
}

.target-trend-view-tab.active {
  background: #edf4ff;
  color: var(--target-blue);
  box-shadow: 0 8px 20px rgba(36, 104, 242, 0.1);
}

.target-metric-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid #dce6f4;
  border-radius: 8px;
  background: #f6f9fd;
  padding: 3px;
}

.target-metric-tab {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52657f;
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  padding: 0 12px;
  white-space: normal;
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1), background 300ms cubic-bezier(0.32, 0.72, 0, 1), color 300ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.target-metric-tab:hover {
  color: var(--target-blue);
}

.target-metric-tab.active {
  background: #fff;
  color: var(--target-blue);
  box-shadow: 0 8px 22px rgba(36, 104, 242, 0.12);
}

.target-trend-plot {
  overflow: hidden;
  border: 1px solid rgba(29, 56, 96, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 250, 251, 0.92)),
    repeating-linear-gradient(0deg, transparent 0, transparent 35px, rgba(36, 104, 242, 0.06) 36px);
}

.target-trend-source {
  display: flex;
  align-items: center;
  gap: 8px 18px;
  min-height: 38px;
  border-block: 1px solid rgba(29, 56, 96, 0.08);
  color: #65758f;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.45;
  padding: 8px 2px;
  flex-wrap: wrap;
}

.target-trend-source > span:not(:first-child) {
  position: relative;
}

.target-trend-source > span:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -10px;
  width: 1px;
  height: 12px;
  background: #dce5ef;
  transform: translateY(-50%);
}

.target-source-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #128151;
  font-weight: 850;
}

.target-source-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(22, 160, 100, 0.1);
}

.target-source-status.syncing {
  color: #2468f2;
}

.target-source-status.fallback,
.target-source-status.stale {
  color: #bd3347;
}

.target-source-status.snapshot {
  color: #6b59d3;
}

.target-trend-plot svg {
  display: block;
  width: 100%;
  height: 230px;
}

.trend-axis {
  stroke: #dde5ef;
  stroke-width: 1.2;
}

.trend-grid line {
  stroke: #e5ebf3;
  stroke-width: 1;
}

.target-trend-plot .trend-grid text {
  fill: #7a8799;
  font-size: 9px;
  font-weight: 760;
}

.trend-line {
  fill: none;
  stroke: var(--target-blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: targetTrendDraw 980ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

.trend-dot {
  fill: #fff;
  stroke: var(--target-blue);
  stroke-width: 3;
}

.target-trend-point {
  outline: none;
}

.target-trend-point:focus .trend-dot,
.target-trend-point:hover .trend-dot,
.target-trend-point.selected .trend-dot {
  fill: #2468f2;
  filter: drop-shadow(0 5px 9px rgba(36, 104, 242, 0.28));
}

.target-trend-point.selected .trend-month,
.target-trend-point .trend-value-label {
  fill: #173c85;
  font-weight: 900;
}

.trend-dot.delay {
  stroke: #d9871f;
}

.trend-dot.stale {
  stroke: #d94d5c;
}

.trend-dot.muted {
  fill: #f8fbfd;
  stroke: #b8c5d6;
  stroke-dasharray: 3 3;
}

.target-daily-bar {
  fill: rgba(36, 104, 242, 0.72);
  transition: fill 180ms ease, filter 180ms ease, transform 180ms ease;
  transform-box: fill-box;
  transform-origin: bottom center;
}

.target-trend-point:hover .target-daily-bar,
.target-trend-point:focus .target-daily-bar {
  fill: #2468f2;
  filter: drop-shadow(0 5px 8px rgba(36, 104, 242, 0.24));
  transform: scaleY(1.025);
}

.target-daily-bar.stale {
  fill: rgba(217, 77, 92, 0.58);
}

.target-daily-bar.delay,
.target-daily-bar.muted {
  fill: rgba(217, 135, 31, 0.12);
  stroke: rgba(217, 135, 31, 0.7);
  stroke-dasharray: 3 3;
}

.target-trend-tooltip {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, visibility 140ms ease;
}

.target-trend-point:hover .target-trend-tooltip,
.target-trend-point:focus .target-trend-tooltip {
  visibility: visible;
  opacity: 1;
}

.target-trend-tooltip rect {
  fill: #14233b;
  stroke: rgba(255, 255, 255, 0.24);
  stroke-width: 1;
  filter: drop-shadow(0 8px 14px rgba(20, 35, 59, 0.24));
}

.target-trend-plot .target-trend-tooltip-date {
  fill: #b9c7dc;
  font-size: 10px;
  font-weight: 800;
}

.target-trend-plot .target-trend-tooltip-value {
  fill: #fff;
  font-size: 12px;
  font-weight: 900;
}

.target-trend-plot text {
  fill: var(--target-ink);
  font-size: 11px;
  font-weight: 850;
}

.target-trend-plot .trend-month {
  fill: #607086;
  font-size: 10px;
}

.db-trend-plot svg {
  height: 260px;
}

.db-trend-day {
  outline: none;
}

.db-trend-hover-band {
  fill: transparent;
}

.db-trend-bar {
  fill: rgba(36, 104, 242, 0.68);
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: targetBarFill 820ms cubic-bezier(0.32, 0.72, 0, 1) both;
  transition: fill 220ms ease, filter 220ms ease, transform 220ms ease;
}

.db-trend-day.stale .db-trend-bar {
  fill: rgba(217, 77, 92, 0.58);
}

.db-trend-day.delay .db-trend-bar {
  fill: rgba(96, 112, 134, 0.08);
  stroke: rgba(96, 112, 134, 0.46);
  stroke-dasharray: 4 4;
}

.db-trend-day:hover .db-trend-hover-band,
.db-trend-day:focus .db-trend-hover-band {
  fill: rgba(36, 104, 242, 0.07);
}

.db-trend-day:hover .db-trend-bar,
.db-trend-day:focus .db-trend-bar {
  fill: #2468f2;
  filter: drop-shadow(0 8px 14px rgba(36, 104, 242, 0.28));
  transform: translateY(-3px);
}

.db-trend-day.delay:hover .db-trend-bar,
.db-trend-day.delay:focus .db-trend-bar {
  fill: rgba(217, 135, 31, 0.42);
  stroke: #d9871f;
}

.db-trend-tooltip {
  opacity: 0;
  pointer-events: none;
  transform-box: fill-box;
  transition: opacity 160ms ease, transform 160ms ease;
}

.db-trend-tooltip rect {
  fill: #17233c;
  stroke: rgba(255, 255, 255, 0.2);
}

.db-trend-tooltip text {
  fill: #fff;
  font-size: 10px;
  font-weight: 850;
}

.db-trend-day:hover .db-trend-tooltip,
.db-trend-day:focus .db-trend-tooltip {
  opacity: 1;
}

.db-delay-zone {
  fill: rgba(217, 135, 31, 0.1);
}

.db-delay-label,
.db-latest-label {
  fill: #607086;
  font-size: 10px;
  font-weight: 850;
}

.db-trend-line {
  stroke: #16a064;
  pointer-events: none;
}

.db-trend-dot {
  stroke: #16a064;
  pointer-events: none;
}

.db-trend-dot.delay {
  fill: #fff8ed;
  stroke: #d9871f;
}

.target-matrix-wrap {
  max-height: 430px;
  border: 1px solid rgba(29, 56, 96, 0.08);
  border-radius: 8px;
  background: #fff;
}

.target-mobile-sort-controls {
  display: none;
}

.target-matrix-table {
  min-width: 1080px;
}

.target-matrix-table th,
.target-matrix-table td {
  white-space: nowrap;
}

.target-matrix-table td:not(:first-child),
.target-matrix-table th:not(:first-child) {
  text-align: right;
}

.target-tier-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tier-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 3px;
  background: var(--target-blue);
  flex: 0 0 auto;
}

.tier-dot.tier-2 {
  background: var(--target-green);
}

.tier-dot.tier-3 {
  background: var(--target-amber);
}

.tier-dot.tier-4 {
  background: var(--target-violet);
}

.tier-dot.black-tier {
  background: #34435f;
}

.target-matrix-total td {
  background: #f8fafc;
  color: var(--target-ink);
  font-weight: 850;
}

.target-matrix-delta {
  justify-content: flex-end;
  width: 100%;
}

.target-matrix-delta.flat {
  color: #7b8798;
}

.target-matrix-delta.total {
  color: #375177;
}

.target-empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed #cdd8e8;
  border-radius: 8px;
  color: #607086;
  font-size: 13px;
  font-weight: 800;
}

.sheet-page .tier-table-panel {
  overflow: hidden;
}

.sheet-page .tier-table-panel .table-toolbar {
  padding: 16px 18px 0;
}

.sheet-page .sheet-table-wrap {
  margin: 0 18px 18px;
  border: 1px solid rgba(29, 56, 96, 0.08);
  border-radius: 8px;
  background: #fff;
}

.target-card-enter {
  animation: targetCardIn 760ms cubic-bezier(0.32, 0.72, 0, 1) both;
  animation-delay: calc(var(--i, 0) * 55ms);
  will-change: transform, opacity;
}

@keyframes targetCardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes targetBarFill {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes targetTrendDraw {
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .target-card-enter,
  .target-progress-bar span,
  .trend-line,
  .db-trend-bar,
  .db-status-skeleton span {
    animation: none;
  }

  .target-progress-card,
  .target-edit-button,
  .target-edit-form button,
  .target-metric-tab {
    transition: none;
  }
}

.tier-category-summary {
  display: grid;
  gap: 12px;
  overflow: hidden;
}

.tier-category-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.tier-category-header h3 {
  color: var(--ink);
  font-size: 15px;
  margin: 0;
}

.tier-category-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.tier-category-header dl {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  margin: 0;
  min-width: min(520px, 100%);
}

.tier-category-header dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.tier-category-header dd {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}

.tier-category-table-wrap {
  max-height: 360px;
}

.tier-category-table th:nth-child(n + 2):nth-child(-n + 6),
.tier-category-table td:nth-child(n + 2):nth-child(-n + 6) {
  text-align: right;
}

.tier-category-table td:first-child p {
  color: var(--muted);
  font-size: 11px;
  margin: 3px 0 0;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.dashboard-category-report {
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.dashboard-category-report > * {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

.dashboard-category-report .tier-category-header {
  padding: 13px 14px 0;
}

.dashboard-category-tier-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 640px;
}

.dashboard-category-tier-option {
  background: #f6f8f9;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink) !important;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  min-height: 32px;
  padding: 6px 9px;
  white-space: nowrap;
}

.dashboard-category-tier-option input {
  margin: 0;
}

.dashboard-category-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr);
  gap: 10px;
  padding: 0 14px;
  align-items: end;
}

.dashboard-category-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-category-controls input,
.dashboard-category-controls select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 6px 9px;
}

.dashboard-category-controls input:focus,
.dashboard-category-controls select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 123, 115, 0.13);
}

.dashboard-category-report-totals {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  margin: 0;
  padding: 0 14px;
}

.dashboard-category-report-totals div {
  background: #f6f8f9;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
}

.dashboard-category-report-totals dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.dashboard-category-report-totals dd {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}

.dashboard-category-table-wrap {
  max-height: 420px;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.dashboard-category-report-table {
  min-width: 1160px;
  table-layout: auto;
}

.dashboard-category-report-table th:nth-child(1),
.dashboard-category-report-table td:nth-child(1) {
  width: 20%;
}

.dashboard-category-report-table th:nth-child(2),
.dashboard-category-report-table td:nth-child(2),
.dashboard-category-report-table th:nth-child(3),
.dashboard-category-report-table td:nth-child(3),
.dashboard-category-report-table th:nth-child(4),
.dashboard-category-report-table td:nth-child(4),
.dashboard-category-report-table th:nth-child(5),
.dashboard-category-report-table td:nth-child(5),
.dashboard-category-report-table th:nth-child(6),
.dashboard-category-report-table td:nth-child(6),
.dashboard-category-report-table th:nth-child(7),
.dashboard-category-report-table td:nth-child(7),
.dashboard-category-report-table th:nth-child(8),
.dashboard-category-report-table td:nth-child(8) {
  width: 8%;
}

.dashboard-category-report-table th:nth-child(9),
.dashboard-category-report-table td:nth-child(9) {
  width: 18%;
}

.dashboard-category-report-table th:nth-child(10),
.dashboard-category-report-table td:nth-child(10) {
  width: 14%;
}

.dashboard-category-report-table th,
.dashboard-category-report-table td {
  white-space: nowrap;
  vertical-align: top;
}

.dashboard-category-report-table .table-sort-button {
  min-height: 24px;
}

.dashboard-category-report-table th:nth-child(9),
.dashboard-category-report-table td:nth-child(9),
.dashboard-category-report-table th:nth-child(10),
.dashboard-category-report-table td:nth-child(10) {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.category-rank-bar {
  display: block;
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.category-rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.dashboard-category-pie {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 18px;
  margin: 0 14px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.category-pie-visual {
  aspect-ratio: 1;
  width: min(220px, 100%);
  justify-self: center;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(37, 48, 56, 0.08);
}

.category-pie-visual > div {
  display: grid;
  place-items: center;
  width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(37, 48, 56, 0.08);
  text-align: center;
  padding: 8px;
}

.category-pie-visual strong {
  color: var(--ink);
  font-size: 12px;
}

.category-pie-visual span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.category-pie-copy {
  min-width: 0;
}

.category-pie-copy h4 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
}

.category-pie-copy p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.category-pie-legend {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-pie-legend li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 7px;
  row-gap: 2px;
  align-items: center;
  min-width: 0;
  font-size: 12px;
}

.category-pie-legend strong,
.category-pie-legend span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-pie-legend span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.category-pie-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.category-pie-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 18px;
}

.logic-summary {
  display: grid;
  gap: 10px;
}

.logic-summary strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.logic-list,
.target-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.logic-list span,
.target-list span {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfc;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.target-list span {
  display: inline-grid;
  gap: 3px;
  max-width: 360px;
}

.sheet-notes-wrap {
  max-width: 100%;
  overflow: auto;
}

.sheet-notes-table {
  min-width: 960px;
}

.sheet-notes-table td {
  background: #fbfcfc;
  color: var(--ink);
}

.sheet-table-wrap {
  max-height: 660px;
}

.sheet-table {
  min-width: 2100px;
}

.table-toolbar {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.table-expand-button,
.table-close-button,
.table-move-button,
.table-reset-moves-button {
  min-width: 72px;
}

.table-move-button {
  min-width: 112px;
}

.table-move-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.62;
}

.table-close-button {
  background: #f7fafb;
}

.tier-move-inline-status {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  min-height: 18px;
}

.sort-group {
  display: flex;
  gap: 6px;
}

.sort-button {
  min-width: 58px;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.sort-button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

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

.sheet-expanded-backdrop {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(25, 35, 43, 0.44);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.sheet-expanded-open {
  overflow: hidden;
}

body.sheet-expanded-open .sheet-expanded-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.tier-table-panel {
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.tier-table-panel.sheet-expanded-panel {
  position: fixed;
  inset: 16px;
  z-index: 39;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--panel);
  border-color: rgba(94, 111, 122, 0.42);
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(25, 35, 43, 0.28);
  animation: tierSheetExpandIn 180ms ease both;
}

.tier-table-panel.sheet-expanded-panel .table-toolbar {
  position: relative;
  z-index: 3;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.tier-table-panel.sheet-expanded-panel .table-wrap,
.tier-table-panel.sheet-expanded-panel .sheet-table-wrap {
  max-height: none;
  min-height: 0;
  height: 100%;
  overscroll-behavior: contain;
}

.tier-table-panel.sheet-expanded-panel .sheet-table {
  min-width: 2100px;
}

.tier-table-panel .tier-select-cell {
  left: 0;
  min-width: 44px;
  padding: 0 10px;
  text-align: center;
  width: 44px;
}

.tier-table-panel th.tier-select-cell {
  z-index: 2;
}

.tier-row-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}

.tier-move-dialog {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(25, 35, 43, 0.42);
  backdrop-filter: blur(6px);
}

body.tier-move-open {
  overflow: hidden;
}

.tier-move-card {
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(94, 111, 122, 0.35);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(25, 35, 43, 0.28);
  animation: tierSheetExpandIn 180ms ease both;
}

.tier-move-header,
.tier-move-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tier-move-header h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.tier-move-header p,
.tier-move-status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tier-move-targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.tier-move-target {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tier-move-target:hover {
  border-color: #b8c4ca;
  background: #f7fafb;
}

.tier-move-target:active {
  transform: translateY(1px);
}

.tier-move-target.active {
  border-color: var(--teal);
  background: rgba(23, 123, 115, 0.08);
  box-shadow: 0 0 0 3px rgba(23, 123, 115, 0.12);
}

.tier-move-target:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.tier-move-target span {
  font-size: 13px;
  font-weight: 850;
}

.tier-move-target small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tier-move-footer {
  justify-content: flex-end;
}

.tier-move-confirm {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.tier-move-confirm:disabled {
  border-color: var(--line);
  background: #eef2f4;
  color: var(--muted);
  cursor: not-allowed;
}

@keyframes tierSheetExpandIn {
  from {
    opacity: 0.94;
    transform: translateY(8px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 940px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #f9fbfb;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  z-index: 1;
}

.tier-category-table {
  min-width: 760px;
  table-layout: fixed;
  width: 100%;
}

.tier-category-table th,
.tier-category-table td {
  overflow-wrap: anywhere;
}

.tier-category-table th:nth-child(1),
.tier-category-table td:nth-child(1) {
  width: 30%;
}

.tier-category-table th:nth-child(2),
.tier-category-table td:nth-child(2),
.tier-category-table th:nth-child(3),
.tier-category-table td:nth-child(3),
.tier-category-table th:nth-child(4),
.tier-category-table td:nth-child(4),
.tier-category-table th:nth-child(5),
.tier-category-table td:nth-child(5),
.tier-category-table th:nth-child(6),
.tier-category-table td:nth-child(6) {
  width: 10%;
}

.tier-category-table th:nth-child(7),
.tier-category-table td:nth-child(7) {
  width: 20%;
}

.tier-category-table.dashboard-category-report-table {
  min-width: 1120px;
  table-layout: fixed;
}

.tier-category-table.dashboard-category-report-table th:nth-child(1),
.tier-category-table.dashboard-category-report-table td:nth-child(1) {
  width: 24%;
}

.tier-category-table.dashboard-category-report-table th:nth-child(2),
.tier-category-table.dashboard-category-report-table td:nth-child(2),
.tier-category-table.dashboard-category-report-table th:nth-child(3),
.tier-category-table.dashboard-category-report-table td:nth-child(3),
.tier-category-table.dashboard-category-report-table th:nth-child(4),
.tier-category-table.dashboard-category-report-table td:nth-child(4),
.tier-category-table.dashboard-category-report-table th:nth-child(5),
.tier-category-table.dashboard-category-report-table td:nth-child(5),
.tier-category-table.dashboard-category-report-table th:nth-child(6),
.tier-category-table.dashboard-category-report-table td:nth-child(6),
.tier-category-table.dashboard-category-report-table th:nth-child(7),
.tier-category-table.dashboard-category-report-table td:nth-child(7),
.tier-category-table.dashboard-category-report-table th:nth-child(8),
.tier-category-table.dashboard-category-report-table td:nth-child(8) {
  width: 8%;
}

.tier-category-table.dashboard-category-report-table th:nth-child(9),
.tier-category-table.dashboard-category-report-table td:nth-child(9) {
  width: 18%;
}

.tier-category-table.dashboard-category-report-table th:nth-child(10),
.tier-category-table.dashboard-category-report-table td:nth-child(10) {
  width: 14%;
}

@keyframes categoryRefreshIn {
  from {
    opacity: 0.72;
    transform: translateY(10px) scale(0.995);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes categorySliceIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

#dashboardCategoryReportBody {
  display: grid;
  gap: 14px;
  min-width: 0;
  position: relative;
}

#dashboardCategoryReportBody.category-report-refreshing .dashboard-category-report-totals,
#dashboardCategoryReportBody.category-report-refreshing .dashboard-category-pie,
#dashboardCategoryReportBody.category-report-refreshing .category-optimization-previews,
#dashboardCategoryReportBody.category-report-refreshing .dashboard-category-table-wrap {
  animation: categoryRefreshIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dashboard-category-report {
  background:
    radial-gradient(circle at 18% 0%, rgba(47, 128, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}

.dashboard-category-report .tier-category-header {
  align-items: flex-start;
  border-bottom: 1px solid rgba(80, 101, 116, 0.1);
  padding: 18px 18px 12px;
}

.dashboard-category-report .tier-category-header h3 {
  font-size: 18px;
  letter-spacing: 0;
}

.dashboard-category-report .tier-category-header p {
  max-width: 58ch;
}

.dashboard-category-tier-picker {
  gap: 7px;
}

.dashboard-category-tier-option {
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(80, 101, 116, 0.18);
  box-shadow: 0 8px 20px rgba(47, 95, 159, 0.06);
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.dashboard-category-tier-option:hover {
  background: #fff;
  border-color: rgba(47, 128, 255, 0.35);
  box-shadow: 0 10px 26px rgba(47, 128, 255, 0.12);
  transform: translateY(-1px);
}

.dashboard-category-tier-option:active {
  transform: translateY(0) scale(0.99);
}

.dashboard-category-tier-option input {
  accent-color: #2f80ff;
}

.dashboard-category-controls {
  padding: 0 18px;
}

.dashboard-category-controls input {
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.dashboard-category-report-totals {
  gap: 10px;
  padding: 0 18px;
}

.dashboard-category-report-totals div {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(80, 101, 116, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.dashboard-category-report-totals dd {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.dashboard-category-pie {
  align-items: center;
  background:
    radial-gradient(circle at 26% 22%, rgba(255, 122, 182, 0.13), transparent 24%),
    radial-gradient(circle at 86% 8%, rgba(47, 128, 255, 0.11), transparent 28%),
    #ffffff;
  border-color: rgba(80, 101, 116, 0.14);
  box-shadow: 0 18px 44px rgba(47, 95, 159, 0.08);
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  margin: 0 18px;
  overflow: visible;
  padding: 18px;
  position: relative;
}

.dashboard-category-pie.category-pie-focused {
  padding-top: 50px;
}

.category-focus-back {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(71, 85, 105, 0.22);
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(47, 95, 159, 0.08);
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  gap: 5px;
  min-height: 30px;
  padding: 0 9px;
  position: absolute;
  right: 12px;
  top: 12px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
  z-index: 5;
}

.category-focus-back svg {
  fill: none;
  height: 14px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  width: 14px;
}

.category-focus-back:hover,
.category-focus-back:focus-visible {
  background: #fff;
  border-color: rgba(47, 128, 255, 0.42);
  color: #1d5fbf;
  outline: none;
  transform: translateY(-1px);
}

.category-focus-back:focus-visible {
  box-shadow: 0 0 0 3px rgba(47, 128, 255, 0.16), 0 8px 20px rgba(47, 95, 159, 0.08);
}

.category-focus-back:active {
  transform: translateY(0) scale(0.98);
}

.category-pie-visual {
  background: linear-gradient(180deg, #fff, #f8fbff);
  border-radius: 50%;
  box-shadow: 0 18px 45px rgba(31, 57, 85, 0.12), inset 0 0 0 1px rgba(80, 101, 116, 0.08);
  overflow: visible;
  position: relative;
  width: min(300px, 100%);
}

.category-pie-svg {
  animation: categorySliceIn 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  display: block;
  overflow: visible;
  width: 100%;
}

.category-pie-track {
  fill: none;
  pointer-events: none;
  stroke: #e7edf2;
  stroke-width: 18;
}

.category-pie-slice {
  fill: none;
  outline: none;
  pointer-events: stroke;
  stroke-linecap: butt;
  stroke-width: 18;
  transition: opacity 180ms ease, stroke-width 180ms ease, filter 180ms ease;
  cursor: pointer;
}

.category-pie-slice:hover,
.category-pie-slice:focus-visible,
.category-pie-slice.category-active {
  filter: drop-shadow(0 7px 12px rgba(33, 48, 63, 0.18));
  stroke-width: 22;
}

.category-pie-spotlight {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(80, 101, 116, 0.12);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), 0 10px 26px rgba(31, 57, 85, 0.08);
  display: grid;
  inset: 25%;
  padding: 14px;
  place-items: center;
  pointer-events: none;
  position: absolute;
  text-align: center;
}

.category-pie-spotlight strong {
  color: var(--ink);
  font-size: 12px;
  max-width: 110px;
}

.category-pie-spotlight span {
  color: var(--leader-color, #2f80ff);
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.category-pie-spotlight small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  max-width: 120px;
}

.category-pie-visual > .category-pie-tooltip {
  aspect-ratio: auto;
  background: rgba(18, 31, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(17, 24, 39, 0.22);
  color: #fff;
  display: grid;
  gap: 4px;
  min-width: 220px;
  max-width: 260px;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  width: auto;
  z-index: 6;
}

.category-pie-visual > .category-pie-tooltip[hidden] {
  display: none;
}

.category-pie-visual > .category-pie-tooltip strong {
  color: #fff;
  font-size: 12px;
}

.category-pie-visual > .category-pie-tooltip span,
.category-pie-visual > .category-pie-tooltip small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  line-height: 1.35;
}

.category-pie-copy h4 {
  font-size: 17px;
  letter-spacing: 0;
}

.category-pie-copy p {
  max-width: 58ch;
}

.category-pie-legend {
  gap: 8px;
}

.category-pie-legend li {
  background: color-mix(in srgb, var(--category-tint) 72%, #fff 28%);
  border: 1px solid rgba(80, 101, 116, 0.1);
  border-left: 4px solid var(--category-color);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px 9px;
  transition: background 180ms ease, border-color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.category-pie-legend li:hover,
.category-pie-legend li:focus-visible,
.category-pie-legend li.category-active {
  background: #fff;
  border-color: color-mix(in srgb, var(--category-color) 42%, #d7e1e7 58%);
  transform: translateY(-1px);
}

.category-pie-swatch {
  background: var(--category-color);
  border-radius: 3px;
}

.category-pie-actions {
  align-items: center;
  background: color-mix(in srgb, var(--category-tint) 70%, #fff 30%);
  border: 1px solid color-mix(in srgb, var(--category-color) 22%, #d7e1e7 78%);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 4px;
  padding: 10px;
}

.category-focus-export {
  background: var(--category-color);
  border: 0;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  min-height: 34px;
  padding: 0 12px;
  transition: filter 180ms ease, transform 180ms ease;
}

.category-focus-export:hover,
.category-focus-export:focus-visible {
  filter: saturate(1.1) brightness(0.98);
  transform: translateY(-1px);
}

.category-pie-actions span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.category-optimization-previews {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 18px;
}

.category-idea-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(80, 101, 116, 0.13);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(47, 95, 159, 0.06);
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.category-idea-heading {
  display: grid;
  gap: 3px;
}

.category-idea-heading span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.category-idea-heading strong {
  color: var(--ink);
  font-size: 14px;
}

.category-metric-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-metric-pills button {
  background: #f3f7fa;
  border: 1px solid rgba(80, 101, 116, 0.14);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  min-height: 28px;
  padding: 0 10px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.category-metric-pills button:hover,
.category-metric-pills button:focus-visible,
.category-metric-pills button.active {
  background: #edf5ff;
  border-color: rgba(47, 128, 255, 0.35);
  color: #1d5fbf;
  transform: translateY(-1px);
}

.category-preview-bars {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-preview-bars li {
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.category-preview-bars span,
.category-preview-bars strong {
  font-size: 11px;
  min-width: 0;
}

.category-preview-bars span {
  color: var(--ink);
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-preview-bars strong {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.category-preview-bars i {
  background: #edf2f5;
  border-radius: 999px;
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
}

.category-preview-bars b {
  background: linear-gradient(90deg, var(--category-color), color-mix(in srgb, var(--category-color) 50%, #fff 50%));
  border-radius: inherit;
  display: block;
  height: 100%;
}

.category-drawer-preview {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--category-tint) 70%, #fff 30%), #fff);
  border: 1px solid color-mix(in srgb, var(--category-color) 24%, #d7e1e7 76%);
  border-left: 5px solid var(--category-color);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.category-drawer-preview dl {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.category-drawer-preview div {
  min-width: 0;
}

.category-drawer-preview dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.category-drawer-preview dd {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  margin: 0;
}

.category-drawer-preview ul {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-drawer-preview li {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.category-drawer-preview li span,
.category-drawer-preview li strong {
  font-size: 11px;
  min-width: 0;
}

.category-drawer-preview li span {
  color: var(--ink);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-drawer-preview li strong {
  color: var(--muted);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.category-tier-mix {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.category-tier-mix-bar {
  background: #edf2f5;
  border-radius: 999px;
  display: flex;
  height: 7px;
  overflow: hidden;
}

.category-tier-mix-bar span {
  background: var(--tier-color);
  min-width: 3px;
}

.category-tier-mix-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
}

.category-tier-mix-labels span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 10px;
  font-weight: 900;
  gap: 4px;
  line-height: 1;
}

.category-tier-mix-labels i {
  background: var(--tier-color);
  border-radius: 2px;
  display: inline-block;
  height: 7px;
  width: 7px;
}

.category-tier-mix-large {
  background: #f8fbfc;
  border: 1px solid rgba(80, 101, 116, 0.12);
  border-radius: 8px;
  padding: 10px;
}

.category-tier-mix-large .category-tier-mix-bar {
  height: 12px;
}

.category-idea-card-tier p {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
  margin: 0;
}

.category-tier-mix-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.dashboard-category-row {
  outline: none;
  transition: background 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.dashboard-category-row:hover,
.dashboard-category-row:focus-visible,
.dashboard-category-row.category-active {
  background: rgba(47, 128, 255, 0.045);
  transform: translateX(2px);
}

.category-name-chip {
  align-items: center;
  background: color-mix(in srgb, var(--category-tint) 70%, #fff 30%);
  border: 1px solid color-mix(in srgb, var(--category-color) 24%, #d7e1e7 76%);
  border-radius: 8px;
  display: inline-flex;
  gap: 7px;
  max-width: 100%;
  padding: 5px 8px;
}

.category-dot {
  background: var(--category-color);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--category-color) 16%, transparent);
  flex: 0 0 auto;
  height: 9px;
  width: 9px;
}

.category-rank-bar span {
  background: linear-gradient(90deg, var(--category-color), color-mix(in srgb, var(--category-color) 55%, #fff 45%));
  transform-origin: left center;
  transition: width 260ms ease;
}

[data-category-highlight].category-dimmed {
  opacity: 0.36;
}

.dashboard-category-row {
  cursor: pointer;
}

.category-expand-chevron {
  align-items: center;
  color: #94a3b8;
  display: inline-flex;
  flex-shrink: 0;
  margin-right: 2px;
  transition: transform 200ms ease, color 200ms ease;
  vertical-align: middle;
}

.category-expanded .category-expand-chevron {
  color: #475569;
  transform: rotate(90deg);
}

.category-expanded-detail {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.category-detail-merchant-row {
  background: #fafcff;
}

.category-detail-merchant-row:hover {
  background: rgba(47, 128, 255, 0.045);
}

.category-detail-merchant-row td {
  padding: 6px 4px;
  vertical-align: middle;
  white-space: nowrap;
}

.category-detail-merchant-row td:first-child {
  padding-left: 28px;
}

.category-detail-merchant-row small {
  color: #94a3b8;
  font-size: 11px;
}

.category-expanded-detail td {
  padding: 0;
}

.category-detail-scroll {
  max-height: 540px;
  overflow: auto;
}

.category-detail-inner-table {
  border-collapse: collapse;
  font-size: inherit;
  width: 100%;
}

.category-detail-inner-table th {
  background: #edf2f7;
  border-bottom: 1px solid #dce2ea;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 14px;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  white-space: nowrap;
  z-index: 1;
}

.category-detail-inner-table th:first-child {
  padding-left: 28px;
}

.category-detail-inner-table th:empty {
  border-bottom: 1px solid #dce2ea;
}

.category-detail-inner-table td {
  border-top: 1px solid #f1f5f9;
  padding: 8px 14px;
}

.category-detail-inner-table tbody tr:first-child td {
  border-top: none;
}

.category-detail-merchant-indent {
  display: inline-block;
  flex-shrink: 0;
  margin-right: 6px;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.table-sort-button:hover,
.table-sort-button.active {
  color: var(--blue);
}

.sort-indicator {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 10px;
}

.sheet-table tr.tier-highlight-row td:first-child,
.sheet-table tr.tier2-phase-row td:first-child {
  border-left: 4px solid transparent;
}

.sheet-table tr.tier-highlight-green td,
.sheet-table tr.tier2-phase-green td {
  background: rgba(23, 123, 115, 0.07);
}

.sheet-table tr.tier-highlight-green td:first-child,
.sheet-table tr.tier2-phase-green td:first-child {
  border-left-color: var(--teal);
}

.sheet-table tr.tier-highlight-yellow td,
.sheet-table tr.tier2-phase-yellow td {
  background: rgba(181, 130, 24, 0.1);
}

.sheet-table tr.tier-highlight-yellow td:first-child,
.sheet-table tr.tier2-phase-yellow td:first-child {
  border-left-color: var(--amber);
}

.sheet-table tr.tier-highlight-red td,
.sheet-table tr.tier2-phase-red td {
  background: rgba(185, 75, 95, 0.1);
}

.sheet-table tr.tier-highlight-red td:first-child,
.sheet-table tr.tier2-phase-red td:first-child {
  border-left-color: var(--rose);
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.phase-green {
  background: var(--green-soft);
  color: var(--teal);
}

.phase-yellow {
  background: var(--amber-soft);
  color: var(--amber);
}

.phase-red {
  background: var(--rose-soft);
  color: var(--rose);
}

td strong {
  display: block;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.tier {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.paid {
  background: var(--green-soft);
  color: var(--teal);
}

.badge.unpaid {
  background: var(--rose-soft);
  color: var(--rose);
}

.badge.overdue {
  background: var(--rose-soft);
  color: var(--rose);
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.neutral {
  background: #eef2f4;
  color: var(--muted);
}

@media (max-width: 1120px) {
  body.tier-scroll-mode {
    overflow: auto;
  }

  body.tier-scroll-mode .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  body.tier-scroll-mode .sidebar,
  body.tier-scroll-mode .workspace {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .filters,
  .dashboard-filters,
  .tier-sheet-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tier-date-range-field {
    grid-column: span 2;
  }

  .sheet-target-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .sheet-page-header,
  .sheet-page .sheet-target-filters,
  .sheet-page .tier-summary,
  .sheet-page .sheet-target-notes {
    grid-column: 1;
    grid-row: auto;
  }

  .sheet-page .sheet-target-filters {
    justify-content: stretch;
    margin-top: 0;
    margin-left: 0;
    max-width: none;
  }

  .sheet-page .tier-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .db-status-grid,
  .db-latest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .db-trend-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-title,
  .checkbox-row,
  .secondary-button {
    grid-column: 1 / -1;
  }

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

  .insight-panel {
    min-height: auto;
  }

  .payment-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .payment-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .payment-filter-search {
    grid-column: span 2;
  }

  .tier-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tier-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tier-category-header,
  .dashboard-category-report-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-category-tier-picker {
    justify-content: flex-start;
    max-width: none;
  }

  .dashboard-category-controls,
  .dashboard-category-pie {
    grid-template-columns: 1fr;
    max-width: 100%;
    min-width: 0;
  }

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

  .category-pie-legend {
    grid-template-columns: 1fr;
  }

  .sheet-picker {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 12px;
  }

  .topbar,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-toolbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .tier-pagination {
    width: 100%;
  }

  .column-picker-panel {
    left: 0;
    right: auto;
  }

  .column-picker-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .tier-table-panel.sheet-expanded-panel {
    inset: 8px;
    border-radius: 8px;
  }

  .tier-table-panel.sheet-expanded-panel .table-toolbar-actions {
    justify-content: space-between;
  }

  .tier-move-inline-status {
    width: 100%;
  }

  .tier-move-card {
    padding: 14px;
  }

  .tier-move-header,
  .tier-move-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .tier-move-targets {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    justify-content: flex-start;
  }

  .metrics,
  .filters,
  .dashboard-filters,
  .payment-summary,
  .payment-filters,
  .tier-sheet-filters,
  .sheet-target-filters,
  .tier-summary {
    grid-template-columns: 1fr 1fr;
  }

  .payment-filter-search {
    grid-column: 1 / -1;
  }

  .tier-date-range-field {
    grid-column: 1 / -1;
  }

  .sheet-page .sheet-target-filters,
  .sheet-page .tier-summary,
  .db-status-grid,
  .db-latest-grid,
  .target-progress-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .payment-status-row {
    gap: 6px;
  }

  .payment-status-pill {
    padding: 9px 8px;
  }

  .payment-status-pill span {
    font-size: 10px;
  }

  .payment-status-pill strong {
    font-size: 16px;
  }

  .target-section-header,
  .target-progress-card-head,
  .target-progress-values {
    align-items: flex-start;
    flex-direction: column;
  }

  .target-metric-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .target-metric-tab {
    min-width: 0;
    padding: 0 8px;
  }

  .target-mobile-sort-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .target-mobile-sort-controls .table-sort-button {
    min-height: 34px;
    border: 1px solid #dce6f4;
    border-radius: 7px;
    background: #fff;
    color: #52657f;
    font-size: 11px;
    font-weight: 850;
    padding: 0 10px;
    text-align: left;
  }

  .target-mobile-sort-controls .table-sort-button.active {
    background: #eef4ff;
    border-color: rgba(36, 104, 242, 0.22);
    color: var(--target-blue);
  }

  .target-matrix-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .target-matrix-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .target-matrix-table thead {
    display: none;
  }

  .target-matrix-table tbody {
    display: grid;
    gap: 10px;
  }

  .target-matrix-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid rgba(29, 56, 96, 0.1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(28, 42, 66, 0.07);
    padding: 10px;
  }

  .target-matrix-table td,
  .target-matrix-table td:not(:first-child) {
    display: grid;
    gap: 4px;
    min-width: 0;
    border: 0;
    padding: 8px 6px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .target-matrix-table td::before {
    content: attr(data-label);
    color: #65758f;
    font-size: 10px;
    font-weight: 850;
    line-height: 1.2;
  }

  .target-matrix-table td:first-child,
  .target-matrix-table td:last-child {
    grid-column: 1 / -1;
  }

  .target-matrix-table td:first-child {
    border-bottom: 1px solid #edf2f7;
    padding-bottom: 10px;
  }

  .target-matrix-table td:first-child::before {
    display: none;
  }

  .target-matrix-table td:last-child {
    border-top: 1px solid #edf2f7;
    padding-top: 10px;
  }

  .target-matrix-table .target-matrix-total {
    background: #f8fafc;
  }

  .target-matrix-total td {
    background: transparent;
  }

  .target-matrix-delta {
    justify-content: flex-start;
    width: auto;
  }

  .target-trend-plot svg {
    height: 170px;
  }

  .target-trend-controls,
  .target-metric-tabs,
  .target-trend-view-tabs {
    width: 100%;
  }

  .target-trend-source {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .target-trend-source > span:not(:first-child)::before {
    display: none;
  }

  .target-trend-controls {
    justify-content: stretch;
  }

  .target-metric-tab,
  .target-trend-view-tab {
    flex: 1 1 0;
    padding: 0 8px;
  }

  .db-chat-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .db-chat-card-head span {
    text-align: left;
  }

  .db-chat-products li {
    grid-template-columns: minmax(0, 1fr);
  }

  .target-edit-form {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .target-value-line {
    flex-wrap: wrap;
  }

  .target-progress-values div:last-child {
    text-align: left;
  }

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

  .context-stats {
    grid-template-columns: 1fr 1fr;
  }

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

  .category-group-summary dl {
    min-width: 0;
    width: 100%;
  }

  .tier-category-header dl,
  .dashboard-category-report-totals {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
    width: 100%;
  }

  .dashboard-category-tier-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .dashboard-category-tier-option {
    min-width: 0;
    white-space: normal;
  }

  .dashboard-category-controls {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .dashboard-category-controls > *,
  .dashboard-category-controls label,
  .dashboard-category-controls .secondary-button {
    min-width: 0;
    width: 100%;
  }

  .dashboard-category-pie {
    box-sizing: border-box;
    overflow: hidden;
  }

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

  .category-focus-export {
    width: 100%;
  }

  .category-pie-visual {
    justify-self: start;
  }

  .download-card {
    align-items: stretch;
    flex-direction: column;
  }

  .download-xlsx-button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .payment-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .target-mobile-sort-controls,
  .target-matrix-table tr {
    grid-template-columns: minmax(0, 1fr);
  }

  .target-report-card {
    padding: 14px;
  }
}

/* ── Loading skeleton (light theme, uses app :root variables) ── */
.app-loading-skeleton {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--bg, #f5f7f8);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.app-loading .app-loading-skeleton {
  opacity: 1;
  visibility: visible;
}

.app-loading-skeleton {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: min(92%, 720px);
}

.skeleton-section {
  background: var(--panel, #ffffff);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow, 0 18px 45px rgba(37, 48, 56, 0.08));
}

.skeleton-heading {
  height: 18px;
  width: 55%;
  border-radius: 6px;
  background: var(--line, #dce3e7);
}

.skeleton-row {
  height: 14px;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line, #dce3e7) 25%, var(--panel, #ffffff) 50%, var(--line, #dce3e7) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.skeleton-row-short {
  width: 65%;
}

.skeleton-message {
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--line, #dce3e7) 25%, var(--panel, #ffffff) 50%, var(--line, #dce3e7) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.skeleton-message-alt {
  width: 75%;
  align-self: flex-end;
}

.skeleton-input {
  height: 40px;
  border-radius: 8px;
  background: var(--line, #dce3e7);
  margin-top: 6px;
}

.skeleton-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #687277);
  letter-spacing: 0.3px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === 深度推理模式切换 === */
.chat-mode-toggle {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  border-color: var(--blue);
  color: var(--ink);
}

.mode-btn.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.mode-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.mode-fast .mode-indicator {
  background: var(--teal);
}

.mode-deep .mode-indicator {
  background: var(--amber);
}

.mode-btn.active .mode-indicator {
  box-shadow: 0 0 4px currentColor;
}

/* === 深度推理覆盖层（非模态浮窗）=== */
/* === 深度分析浮窗（多重实例）=== */
.deep-window {
  position: fixed;
  z-index: 1000;
  width: min(760px, 88vw);
  max-height: 80vh;
  background: var(--panel);
  border-radius: 18px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 6px 20px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  transition: box-shadow 0.25s ease;
}

.deep-window.dragging {
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.2),
    0 8px 28px rgba(0, 0, 0, 0.12);
  transition: none;
}

.deep-window-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  cursor: grab;
  user-select: none;
}
.deep-window-header:active {
  cursor: grabbing;
}

/* 顶部装饰线 */
.deep-window-header::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--line);
  border-radius: 0 0 3px 3px;
}

.deep-window-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1a1f22;
  letter-spacing: -0.01em;
}

.deep-window-header::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--muted);
  border-radius: 2px;
  margin-right: 10px;
  opacity: 0.3;
  flex-shrink: 0;
}

.deep-window-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.deep-window-export,
.deep-window-close,
.deep-window-minimize {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
  line-height: 1.4;
}

.deep-window-minimize {
  font-size: 18px;
  padding: 3px 10px;
}

.deep-window-export:hover,
.deep-window-minimize:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.deep-window-close:hover {
  background: var(--rose-soft);
  color: var(--rose);
}

.deep-window.generating .deep-window-minimize {
  display: none;
}

.deep-window-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}

/* 骨架屏 */
.deep-window-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 0;
}

.deep-skeleton-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 14px;
  transition: all 0.3s ease;
  border-radius: 8px;
}

.deep-skeleton-step.active {
  color: var(--blue);
  font-weight: 600;
  background: color-mix(in srgb, var(--blue) 4%, transparent);
}

.deep-skeleton-step.done {
  color: var(--teal);
}

.deep-skeleton-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: deep-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.deep-skeleton-step.done .deep-skeleton-spinner {
  border-color: var(--teal);
  animation: none;
  position: relative;
}

.deep-skeleton-step.done .deep-skeleton-spinner::after {
  content: "✓";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  position: absolute;
  inset: 0;
}

@keyframes deep-spin {
  to { transform: rotate(360deg); }
}

/* 报告内容 */
.deep-window-content {
  animation: deep-fade-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.deep-window-content.hidden,
.deep-window-error.hidden,
.deep-window-skeleton.hidden {
  display: none;
}

@keyframes deep-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes deep-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.deep-report-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-bottom: 12px;
  color: #1a1f22;
  border-bottom: 1px solid var(--line);
  letter-spacing: -0.01em;
}

.deep-report-summary {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  margin-top: 14px;
  padding: 14px 18px;
  background: var(--bg);
  border-radius: 8px;
  line-height: 1.6;
  border-left: 3px solid var(--line);
}

.deep-report-section {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow-x: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: box-shadow 0.2s ease;
}

.deep-report-section:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.deep-report-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.deep-report-section h3::before {
  content: "";
  width: 3px;
  height: 14px;
  background: var(--muted);
  border-radius: 2px;
  opacity: 0.3;
  flex-shrink: 0;
}

.deep-report-findings {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.deep-report-findings li {
  padding: 5px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  padding-left: 18px;
  position: relative;
}

.deep-report-findings li::before {
  content: "▸";
  color: var(--muted);
  font-size: 9px;
  position: absolute;
  left: 2px;
  top: 7px;
  opacity: 0.5;
}

/* ── Deep Analysis 表格 — 专业数据分析风格 ── */
/* 设计原则：干净、精确、层次分明。放弃蓝色模板和交替行色，
   用间距、字重和微妙分隔线建立视觉层次。 */

.deep-report-table {
  width: auto;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: auto;
  white-space: nowrap;
}

/* 表头：深灰背景，白色文字，不转大写，保持清晰 */
.deep-report-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.deep-report-table th {
  text-align: left;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.deep-report-table th:first-child {
  border-radius: 6px 0 0 0;
}

.deep-report-table th:last-child {
  border-radius: 0 6px 0 0;
}

/* 数据单元格：干净的行分隔线，不显眼 */
.deep-report-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #eef1f3;
  line-height: 1.5;
  vertical-align: middle;
  color: #1e2528;
  font-size: 13px;
  background: #fff;
  transition: background 0.12s ease;
}

/* 首列：品牌/实体名。th 保持白色文字（深灰背景上），td 半粗体 */
.deep-report-table th:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

.deep-report-table td:first-child {
  font-weight: 600;
  color: #1a1f22;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

/* 数字列：右对齐，等宽数字 */
.deep-report-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
  font-feature-settings: "tnum" 1;
}

/* 行悬停：浅灰高亮 */
.deep-report-table tbody tr:hover td {
  background: #f4f5f6;
}

/* 每行独立圆角，无交错色 */
.deep-report-table tbody tr:last-child td {
  border-bottom: none;
}

/* 首行无上方边框 */
.deep-report-table tbody tr:first-child td {
  border-top: none;
}

/* 外容器 */
.deep-table-wrap {
  display: inline-block;
  max-width: 100%;
  min-width: 200px;
  overflow-x: auto;
  border-radius: 6px;
  margin-top: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.severity-high {
  border-left: 3px solid var(--rose);
}

.severity-medium {
  border-left: 3px solid var(--amber);
}

.severity-low {
  border-left: 3px solid var(--teal);
}

/* 摘要消息（聊天流中） */
.deep-summary-card {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.deep-summary-card:hover {
  background: #f4f5f6;
  border-color: #c8d0d5;
}

.deep-summary-card::before {
  content: "📊";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 28px;
  opacity: 0.15;
}

.deep-summary-card:hover {
  border-color: var(--amber);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.deep-summary-card h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  padding-right: 36px;
}

.deep-summary-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding-right: 36px;
}

/* === 深度推理停止按钮 === */
.deep-window-stop {
  padding: 6px 16px;
  border: 1px solid var(--rose);
  border-radius: 8px;
  background: var(--rose-soft, #fff0f0);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--rose, #e53e3e);
  transition: all 0.15s ease;
  display: none;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.deep-window-stop::before {
  content: "■";
  font-size: 10px;
}

.deep-window-stop:hover {
  background: var(--rose, #e53e3e);
  color: #fff;
  border-color: var(--rose, #e53e3e);
}

.deep-window-stop:not(.hidden) {
  display: inline-flex;
}

/* 生成中状态——隐藏关闭和导出按钮 */
.deep-window.generating .deep-window-close {
  display: none;
}

.deep-window.generating .deep-window-export {
  display: none;
}

/* === 最小化浮窗（独立可拖拽药丸）=== */
.deep-window.minimized {
  width: auto !important;
  min-width: 160px;
  max-width: 280px;
  height: auto !important;
  border-radius: 100px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-radius 0.2s ease;
  overflow: visible;
}
.deep-window.minimized:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.deep-window.minimized .deep-window-body {
  display: none !important;
}
.deep-window.minimized .deep-window-header {
  padding: 5px 6px 5px 18px;
  border-bottom: none;
  border-radius: 100px;
  cursor: grab;
  background: var(--panel);
}
.deep-window.minimized .deep-window-header:active {
  cursor: grabbing;
}
.deep-window.minimized .deep-window-header h2 {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  margin: 0;
}
.deep-window.minimized .deep-window-header::before,
.deep-window.minimized .deep-window-header::after {
  display: none;
}
.deep-window.minimized .deep-window-export,
.deep-window.minimized .deep-window-stop {
  display: none !important;
}
.deep-window.minimized .deep-window-actions {
  gap: 0;
}

/* === 浮动深度分析按钮（FAB）=== */
.deep-analysis-fab {
  position: fixed;
  bottom: 120px;
  right: 32px;
  z-index: 999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--blue), #4f7cff);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.35);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}

.deep-analysis-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 24px rgba(0, 102, 255, 0.5);
}

.deep-analysis-fab:active {
  transform: scale(0.95);
}

.deep-analysis-fab.hidden {
  display: none;
}

/* 小屏适配 */
@media (max-width: 640px) {
  .tier-date-range-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .tier-date-range-separator {
    display: none;
  }

  .tier-sheet-filters .tier-date-apply {
    grid-column: 1 / -1;
  }

  .deep-analysis-fab {
    bottom: 100px;
    right: 20px;
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
}

/* ── Publishers Page ───────────────────────────────────────────── */

.publishers-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.publishers-page.hidden {
  display: none;
}

.publishers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.publishers-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.publishers-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── 筛选区 ── */

.publishers-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.publishers-filter-row {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}

.publishers-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  flex: 1;
}

.publishers-filter-group label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.publishers-filter-group label select,
.publishers-filter-group label input {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  min-width: 110px;
  height: 30px;
  box-sizing: border-box;
}

.publishers-filter-group label input {
  min-width: 120px;
}

/* 自定义组合框（经理输入） */
.publishers-combobox {
  position: relative;
  min-width: 120px;
}

.publishers-combobox input {
  width: 100%;
  min-width: 0 !important;
  padding-right: 24px !important;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.publishers-combobox-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.publishers-combobox-dropdown.show {
  display: block;
}

.publishers-combobox-dropdown .combobox-option {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.1s;
}

.publishers-combobox-dropdown .combobox-option:hover,
.publishers-combobox-dropdown .combobox-option.highlighted {
  background: #eef2ff;
}

.publishers-combobox-dropdown .combobox-option .opt-count {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

/* 日期范围组合 */
.publishers-filter-date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.publishers-filter-date-range input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  height: 30px;
  box-sizing: border-box;
  min-width: 0;
  width: 130px;
}

.date-quick-btns {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.date-quick-btns button {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8f9fa;
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.date-quick-btns button:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.date-separator {
  color: var(--muted);
  font-size: 14px;
  padding: 0 2px;
}

.publishers-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── 筛选操作按钮 ── */

.publishers-filter-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
  height: 30px;
}

.publishers-filter-actions button svg {
  fill: currentColor;
  flex-shrink: 0;
}

.publishers-filter-actions button:hover {
  opacity: 0.9;
}

.publishers-filter-actions button:active {
  transform: scale(0.97);
}

.btn-search {
  background: #22c55e;
}

.btn-reset {
  background: #f97316;
}

.btn-export {
  background: #3b82f6;
}

/* ── KPI 指标卡 ── */

.publishers-kpi {
  width: 100%;
}

.publishers-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.publishers-kpi-row .metric {
  flex: 1;
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.publishers-kpi-row .metric:hover {
  border-color: var(--blue-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.publishers-kpi-row .metric.metric-active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.publishers-kpi-row .metric span {
  font-size: 13px;
  color: var(--muted);
}

.publishers-kpi-row .metric strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

/* ── 横向柱状图 ── */

.publishers-chart-panel {
  padding: 16px;
}

.publishers-chart-panel .panel-title h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.publishers-chart {
  width: 100%;
  overflow-x: auto;
}

.publishers-chart .chart-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}

.publishers-chart .chart-bar-label {
  width: 160px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--ink);
}

.publishers-chart .chart-bar-track {
  flex: 1;
  height: 24px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}

.publishers-chart .chart-bar-fill {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  transform-origin: left;
  animation: publishersBarGrow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  /* width 由 inline style 设置，transform: scaleX 动画实现生长效果 */
  padding-right: 6px;
  font-size: 11px;
  color: #fff;
  font-weight: 600;
  min-width: fit-content;
}

.publishers-chart .chart-bar-value {
  width: 80px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  flex-shrink: 0;
}

/* ── 数据表格 ── */

.publishers-table-panel {
  padding: 0;
}

.publishers-table-wrap {
  overflow-x: auto;
}

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

.publishers-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.publishers-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.publishers-table tbody tr:hover {
  background: var(--blue-soft);
}

.publishers-table tbody tr.total-row {
  background: #f0f2f4;
  font-weight: 600;
}

.publishers-table tbody tr.total-row td {
  border-top: 2px solid var(--line);
}

/* ── 柱状图动画 ── */

@keyframes publishersBarGrow {
  0% {
    transform: scaleX(0);
    opacity: 0;
  }
  65% {
    transform: scaleX(1.04);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* ── 空状态 ── */

.publishers-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
}

/* ── 加载状态 ── */

.publishers-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
}
