:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #20242c;
  --muted: #68707e;
  --soft: #f4f6f8;
  --active: #eef1f5;
  --brand-ink: #33363d;
  --brand-accent: #2f6f4f;
  --brand-accent-2: #245fc8;
  --brand-soft: #edf7f1;
  --green-bg: #eaf7ef;
  --green: #16733d;
  --amber-bg: #fff6e8;
  --amber: #9a5b05;
  --red-bg: #fff0f1;
  --red: #b4233a;
  --blue: #245fc8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fbfcfd 0, var(--bg) 180px),
    var(--bg);
  color: var(--text);
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; letter-spacing: 0; }

.app {
  min-height: 100vh;
  display: block;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: 64px;
  padding: 5px 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 251, 0.94));
  border-bottom: 1px solid #dbe3df;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(16px) saturate(155%);
  -webkit-backdrop-filter: blur(16px) saturate(155%);
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-2), #c8a24a);
}

.brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  min-height: 62px;
  padding: 0;
  border: 1px solid #d8e4dd;
  border-radius: 15px;
  background: linear-gradient(180deg, #ffffff, #fbfcfb);
  overflow: visible;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(47, 111, 79, 0.08);
  text-align: left;
}

.brand-logo {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: visible;
  border-radius: 13px;
  background: transparent;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 0;
  justify-items: start;
  padding-right: 3px;
}

.brand h1 {
  color: var(--brand-ink);
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.08;
}
.brand p, .sidebar-note span, .section-title span, .page-header .eyebrow, small { color: var(--muted); }
.brand p {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--brand-accent);
}

nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 3px;
  border: 1px solid #d8e0e7;
  border-radius: 13px;
  background: #eef2f5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-item {
  min-height: 32px;
  width: auto;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: center;
  padding: 6px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.nav-item:hover { background: #fff; color: var(--text); }
.nav-item.active {
  background: #fff;
  border-color: #d4dce5;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.09), 0 8px 20px rgba(15, 23, 42, 0.07);
}

.nav-signout {
  margin-left: 8px;
  border: 1px solid #d8e4dd;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  opacity: 0.85;
  cursor: pointer;
  white-space: nowrap;
}
.nav-signout:hover { opacity: 1; background: var(--soft); }

.sidebar-note {
  margin-left: auto;
  min-height: 34px;
  padding: 8px 12px 8px 10px;
  border: 1px solid #d8e4dd;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.sidebar-note span { display: none; }
.sidebar-note strong {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 16px;
  white-space: nowrap;
}

.sidebar-note strong::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 115, 61, 0.12);
  vertical-align: 1px;
}

.content {
  width: min(100%, 1320px);
  min-width: 0;
  margin: 0 auto;
  padding: 22px clamp(18px, 2.4vw, 32px) 48px;
}

body.table-mode .content {
  width: 100%;
  max-width: none;
  padding: 16px clamp(14px, 1.4vw, 24px) 28px;
}

.view { display: none; }
.view.active { display: block; }

.page-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h2 { font-size: 25px; line-height: 1.1; }
.eyebrow { margin-bottom: 5px; font-size: 12px; font-weight: 700; }
.dashboard-subtitle {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.table-source {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.table-header-meta {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-header-meta span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 3px 8px;
}

.secondary {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
}

.secondary:hover { background: var(--soft); }
.secondary.compact { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.secondary.danger { color: var(--red); }
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.notice {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.notice.show { display: block; }
.notice.error { border-left-color: var(--red); }
#tableNotice { display: none !important; }

.section {
  padding: 20px 0 28px;
  border-bottom: 1px solid var(--line);
}

.section:first-of-type { padding-top: 0; }
.section-title { margin-bottom: 14px; }
.section-title h3 { font-size: 23px; line-height: 1.2; margin-bottom: 8px; }
.section-title.compact {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.section-title.compact h3 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.25;
}
.section-title.compact span {
  font-size: 12px;
  font-weight: 700;
}

.dashboard-overview {
  padding-bottom: 22px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 8px;
}

.metrics.three { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.metrics.four { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.metrics.churn-layout { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.churn-layout article { grid-column: span 3; }
.churn-layout article.churn-wide { grid-column: span 6; }
.churn-layout article.churn-rolling { grid-column: span 4; }

article, .panel, .chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

article {
  min-height: 86px;
  padding: 14px 18px;
}

.metric-card {
  min-height: 100px;
  padding: 15px 16px;
  border-color: #dfe7e2;
  background:
    linear-gradient(180deg, #ffffff, #fbfcfb);
}

.metric-card.metric-primary {
  border-color: #cfe1d5;
  background:
    linear-gradient(180deg, #f8fcfa, #ffffff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 28px rgba(47, 111, 79, 0.08);
}

.metric-card.metric-risk {
  border-color: #f0d5d9;
  background:
    linear-gradient(180deg, #fffafa, #ffffff);
}

article span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

article strong {
  display: block;
  font-size: 29px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.metric-card strong { font-size: 27px; }
.metric-card.metric-primary strong { font-size: 32px; color: var(--brand-accent); }
.metric-card.metric-risk strong { color: var(--red); }

article small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
}

.panel {
  overflow: hidden;
  margin: 8px 0 28px;
}

.panel-title {
  padding: 14px 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head .panel-title {
  padding: 0;
  border-bottom: 0;
  font-size: 15px;
  font-weight: 800;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.forecast-panel {
  border-color: #dbe5df;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 16px 38px rgba(15, 23, 42, 0.05);
}

.forecast-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(104px, 1fr));
  gap: 7px;
  min-width: min(560px, 100%);
}

.forecast-summary span {
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  background: #fff;
}

.forecast-summary strong,
.forecast-summary small {
  display: block;
}

.forecast-summary strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.forecast-summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
}

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

th, td {
  text-align: left;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fcfcfd;
  cursor: pointer;
  user-select: none;
}

tr:hover td { background: var(--soft); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.forecast-panel table {
  min-width: 760px;
}

.forecast-panel th,
.forecast-panel td {
  padding: 13px 18px;
  vertical-align: middle;
}

.forecast-panel thead th {
  color: #5f6875;
  font-weight: 800;
  background: #f7faf8;
  cursor: default;
}

.forecast-panel tbody th {
  min-width: 160px;
  color: var(--text);
  background: #fff;
  cursor: default;
}

.forecast-panel tbody tr:nth-child(even) th,
.forecast-panel tbody tr:nth-child(even) td {
  background: #fcfdfd;
}

.forecast-panel tbody tr:hover th,
.forecast-panel tbody tr:hover td {
  background: #f5f8f6;
}

.forecast-panel .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.forecast-month {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.forecast-panel tbody th small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.forecast-mrr-cell {
  min-width: 190px;
}

.forecast-mrr-cell strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.forecast-bar {
  display: block;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eff0;
}

.forecast-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent-2));
}

.forecast-delta {
  font-weight: 800;
}

.forecast-delta.positive { color: var(--green); }
.forecast-delta.negative { color: var(--red); }
.forecast-delta.neutral { color: var(--muted); }

.forecast-peak .forecast-month::after {
  content: "Peak";
  min-height: 19px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfe1d5;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-accent);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 800;
}

.two-blocks { display: grid; gap: 28px; }

.chart-card {
  min-height: 360px;
  margin-top: 8px;
  padding: 14px 18px 18px;
  position: relative;
}

.chart-card svg {
  width: 100%;
  height: 328px;
  display: block;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  stroke: #c7ccd4;
  stroke-width: 1.2;
}

.chart-card polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.chart-points circle {
  fill: #fff;
  stroke: var(--blue);
  stroke-width: 2;
}

.chart-point {
  cursor: pointer;
}

.chart-point:hover,
.chart-point:focus {
  fill: var(--blue);
  outline: none;
  stroke-width: 3;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity 120ms ease;
  visibility: hidden;
}

.chart-tooltip.show {
  opacity: 1;
  visibility: visible;
}

.chart-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.chart-tooltip span,
.chart-tooltip strong {
  display: block;
  white-space: nowrap;
}

.chart-tooltip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-tooltip strong {
  margin-top: 2px;
  font-size: 16px;
}

.chart-y-label,
.chart-x-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-y-label {
  font-weight: 600;
}

.chart-x-label {
  font-weight: 500;
}

.chart-caption {
  display: none;
  color: var(--muted);
  font-size: 12px;
}

.status-pill, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.green { background: var(--green-bg); color: var(--green); border-color: #bfe7cc; }
.tag.amber { background: var(--amber-bg); color: var(--amber); border-color: #f3d29a; }
.tag.red { background: var(--red-bg); color: var(--red); border-color: #f5c1ca; }
.tag.gray { background: var(--soft); color: var(--muted); }

.data-workspace {
  min-height: 640px;
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

body.table-mode .data-workspace {
  height: calc(100vh - 116px);
  min-height: 620px;
  border-radius: 8px;
}

body.table-mode .grid-workspace {
  min-height: 0;
}

body.table-mode .table-panel {
  min-height: 0;
  overflow: hidden;
}

body.table-mode .table-panel .table-scroll {
  height: 100%;
  overflow: auto;
}

.views-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #fcfcfd;
  display: flex;
  flex-direction: column;
}

.views-panel-head {
  min-height: 58px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.views-panel-head div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.views-panel-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
}

.views-panel-head strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.views-tree {
  padding: 8px;
  overflow: auto;
}

.view-group + .view-group { margin-top: 10px; }

.view-table,
.view-tab {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.view-table {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
}

.view-tab {
  padding: 6px 8px 6px 22px;
  font-size: 13px;
}

.view-table span,
.view-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-table small,
.view-tab small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.view-table:hover,
.view-tab:hover { background: var(--soft); }

.view-tab--thrivecart {
  background: #eaf3ff;
  border-color: #bedbff;
  color: #1757a6;
  font-weight: 800;
}

.view-tab--thrivecart small {
  color: #2f6fbd;
}

.view-tab--thrivecart:hover {
  background: #dcebff;
  border-color: #9dcbff;
}

.view-table.active,
.view-tab.active {
  background: var(--active);
  border-color: #d7dce4;
  font-weight: 800;
}

.view-tab--thrivecart.active {
  background: #d8ebff;
  border-color: #65a9f4;
  box-shadow: inset 3px 0 0 #1d73d4;
  color: #0f4d95;
}

.view-actions {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 6px;
}

.grid-workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.table-context-bar {
  min-height: 58px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.table-context-bar h2 {
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
}

.table-context-bar .table-source {
  margin-top: 3px;
}

.view-toolbar {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px;
}

.toolbar-menu { position: relative; }

.tool-button {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 13px;
}

.tool-button:hover,
.tool-button[aria-expanded="true"] {
  background: var(--soft);
  border-color: var(--line);
}

.tool-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary-tool {
  border-color: #bfd0f2;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 700;
}

.primary-tool:hover { background: #e4edff; }

.tool-button span {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

.table-statusbar {
  min-height: 43px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
}

.table-status-main,
.table-chips {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.table-status-main strong {
  color: var(--text);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 115, 61, 0.12);
}

.status-dot.loading {
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 95, 200, 0.12);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 58, 0.12);
}

.table-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.table-chip strong {
  color: var(--text);
  font-size: 12px;
}

.tool-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(360px, 86vw);
  max-height: 410px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
}

.tool-panel[hidden] { display: none; }

.control-panel {
  display: grid;
  gap: 10px;
}

.control-panel label,
.toolbar-search {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar-search {
  margin-left: auto;
  min-width: min(250px, 100%);
}

.control-panel input,
.control-panel select,
.toolbar-search input,
.fields-dropdown input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 8px;
}

.fields-dropdown-head,
.field-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.field-actions { justify-content: flex-start; margin-top: 10px; }

.fields-dropdown-head span,
.muted-empty {
  color: var(--muted);
  font-size: 12px;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.row-number-col,
.row-number,
.record-count {
  width: 62px;
  min-width: 62px;
  max-width: 92px;
  color: var(--muted);
  background: #fcfcfd;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-number-col,
.row-number {
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 1px solid var(--line);
}

.row-number-col { z-index: 4; }
tr:hover .row-number { background: var(--soft); }

.table-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  flex: 1;
}

.column-head {
  width: 100%;
  min-height: 22px;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
}

.column-title {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-menu-indicator {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.sort-badge {
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfd0f2;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
}

.row-height-compact th,
.row-height-compact td { padding-top: 7px; padding-bottom: 7px; }
.row-height-normal th,
.row-height-normal td { padding-top: 11px; padding-bottom: 11px; }
.row-height-tall th,
.row-height-tall td { padding-top: 17px; padding-bottom: 17px; }

.data-row { cursor: pointer; }
.data-row:hover td { background: var(--soft); }

.is-refreshing tbody {
  opacity: 0.72;
}

.skeleton-row td span {
  display: block;
  width: min(140px, 75%);
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef1f5, #f8f9fb, #eef1f5);
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-row .row-number {
  color: transparent;
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

.empty-state {
  height: 180px;
  white-space: normal;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
}

.empty-state span {
  color: var(--muted);
  font-size: 12px;
}

tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #fcfcfd;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tfoot .record-count {
  left: 0;
  z-index: 5;
  white-space: normal;
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: -16px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preview-actions[hidden] { display: none; }

.group-row td {
  background: var(--active);
  color: var(--text);
  font-weight: 800;
}

.group-toggle {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  margin-right: 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.group-label {
  color: var(--text);
}

.group-row .group-count {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 600;
}

.column-menu {
  position: fixed;
  z-index: 80;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
}

.column-menu[hidden] { display: none; }
.column-menu-title {
  padding: 6px 8px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.column-menu button {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
}
.column-menu button:hover { background: var(--soft); }

.record-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  width: min(440px, 94vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -24px 0 60px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
}

.record-drawer[hidden] { display: none; }

.record-drawer-head {
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-drawer-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.record-drawer-head strong {
  display: block;
  font-size: 18px;
}

.record-fields {
  overflow: auto;
  padding: 10px 16px 24px;
}

.record-field {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.record-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.record-field strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 1180px) {
  .data-workspace { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .metrics, .metrics.three, .metrics.four, .metrics.churn-layout { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .churn-layout article,
  .churn-layout article.churn-wide,
  .churn-layout article.churn-rolling { grid-column: span 1; }
  .panel-head { flex-direction: column; }
  .forecast-summary {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .content { padding: 18px 14px 36px; }
  .sidebar { padding: 5px 12px; gap: 8px; }
  .brand { width: 58px; min-height: 58px; padding: 0; }
  .brand-logo { width: 54px; height: 54px; }
  .brand-copy,
  .brand p { display: none; }
  nav {
    order: 0;
    width: auto;
    margin-left: auto;
    flex: 0 0 auto;
  }
  .nav-item {
    flex: 0 0 auto;
    padding-left: 8px;
    padding-right: 8px;
  }
  .sidebar-note { display: none; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .table-header-meta { justify-content: flex-start; }
  .metrics, .metrics.three, .metrics.four, .metrics.churn-layout { grid-template-columns: 1fr; }
  .dashboard-overview .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title.compact {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
  .metric-card {
    min-height: 92px;
    padding: 13px;
  }
  .metric-card strong { font-size: 23px; }
  .metric-card.metric-primary strong { font-size: 26px; }
  .panel-head { padding: 14px; }
  .forecast-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .forecast-panel table { min-width: 680px; }
  .data-workspace { grid-template-columns: 1fr; }
  body.table-mode .data-workspace {
    height: auto;
    min-height: calc(100vh - 102px);
  }
  body.table-mode .table-panel .table-scroll {
    max-height: 62vh;
  }
  .views-panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 280px; }
  .table-context-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
  }
  .table-statusbar { align-items: flex-start; flex-direction: column; }
  .toolbar-search { margin-left: 0; width: 100%; }
  .record-field { grid-template-columns: 1fr; gap: 4px; }
}
