: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 {
  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;
}

.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;
}

.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;
}

.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;
}

.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;
}

.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: 2fr repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.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-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-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-plot svg {
  display: block;
  width: 100%;
  height: 230px;
}

.trend-axis {
  stroke: #dde5ef;
  stroke-width: 1.2;
}

.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-plot text {
  fill: var(--target-ink);
  font-size: 11px;
  font-weight: 850;
}

.target-trend-plot .trend-month {
  fill: #607086;
  font-size: 10px;
}

.db-status-card {
  position: relative;
  overflow: hidden;
}

.db-status-head {
  align-items: center;
}

.db-health-pill {
  border-color: rgba(36, 104, 242, 0.2);
  background: #edf4ff;
  color: #2468f2;
}

.db-health-pill.fresh {
  border-color: rgba(22, 160, 100, 0.22);
  background: #e7f6ef;
  color: #128151;
}

.db-health-pill.stale {
  border-color: rgba(217, 77, 92, 0.22);
  background: #fff0f2;
  color: #bd3347;
}

.db-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.db-mini-card {
  min-height: 104px;
  border: 1px solid rgba(29, 56, 96, 0.1);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.db-mini-card span,
.db-latest-grid span,
.db-trend-aside span {
  display: block;
  color: #65758f;
  font-size: 11px;
  font-weight: 850;
}

.db-mini-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--target-ink);
  font-size: 21px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.db-mini-card small,
.db-latest-grid small,
.db-trend-aside small {
  color: #65758f;
  font-size: 11px;
  font-weight: 800;
}

.db-mini-card.green {
  background: linear-gradient(180deg, #fff, #f0fbf6);
}

.db-mini-card.blue {
  background: linear-gradient(180deg, #fff, #f1f6ff);
}

.db-mini-card.amber {
  background: linear-gradient(180deg, #fff, #fff7ea);
}

.db-mini-card.slate {
  background: linear-gradient(180deg, #fff, #f4f7fb);
}

.db-latest-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.db-latest-grid > div {
  border: 1px solid rgba(29, 56, 96, 0.08);
  border-radius: 8px;
  background: rgba(248, 251, 253, 0.82);
  padding: 12px;
}

.db-latest-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--target-ink);
  font-size: 14px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.db-trend-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  gap: 14px;
  align-items: stretch;
}

.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;
}

.db-trend-aside {
  display: grid;
  align-content: center;
  gap: 10px;
  border: 1px solid rgba(29, 56, 96, 0.1);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f8fbfd);
  padding: 16px;
}

.db-trend-aside strong {
  color: var(--target-ink);
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.db-trend-aside p {
  color: #465979;
  font-size: 13px;
  font-weight: 850;
}

.db-status-skeleton {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.db-status-skeleton span {
  min-height: 84px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef3f9, #f8fbff, #eef3f9);
  background-size: 220% 100%;
  animation: dbStatusPulse 1.2s ease-in-out infinite;
}

@keyframes dbStatusPulse {
  0% {
    background-position: 0 50%;
  }

  100% {
    background-position: -220% 50%;
  }
}

.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;
}

.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;
}

.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) {
  .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));
  }

  .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%;
  }

  .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;
  }

  .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;
  }

  .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;
  }
}
