.simple-profitability,
body:has(.simple-profitability) .detail-dialog {
  --sp-brand: #2563eb;
  --sp-blue-dark: #1e40af;
  --sp-blue-light: #93c5fd;
  --sp-blue-wash: #eff6ff;
}
.simple-profitability {
  --sp-ink: #171717;
  --sp-muted: #686868;
  --sp-line: #e5e5e5;
  max-width: 1280px;
  margin-inline: auto;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  color: var(--sp-ink);
}
.simple-profitability :is(h1, h2, h3, p) {
  overflow-wrap: anywhere;
}
.sp-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}
.sp-heading h1 {
  font-size: 30px;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin: 0 0 8px;
}
.sp-heading .subtext,
.sp-help {
  color: var(--sp-muted);
  font-size: 13px;
  line-height: 1.65;
  max-width: 850px;
}
.sp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--sp-line);
  margin-bottom: 22px;
}
.simple-profitability button {
  min-height: 40px;
  font-weight: 600;
}
.sp-tabs button {
  padding: 10px 16px;
  background: #fff;
}
.sp-tabs [aria-current="page"] {
  background: var(--sp-brand);
  border-color: var(--sp-brand);
  color: #fff;
}
.sp-tabs [aria-current="page"]:hover {
  background: var(--sp-blue-dark);
  border-color: var(--sp-blue-dark);
  color: #fff;
}
.simple-profitability button.primary {
  background: var(--sp-brand);
  border-color: var(--sp-brand);
  color: #fff;
}
.simple-profitability button.primary:hover:not(:disabled) {
  background: var(--sp-blue-dark);
  border-color: var(--sp-blue-dark);
  color: #fff;
}
.simple-profitability button:disabled {
  opacity: 1;
  background: #777;
  border-color: #777;
  color: #fff;
}
.simple-profitability :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--sp-ink);
  outline-offset: 3px;
}
.simple-profitability a {
  color: var(--sp-blue-dark);
  text-underline-offset: 3px;
}
.sp-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.sp-toolbar .field {
  min-width: 140px;
}
.simple-profitability .field {
  display: grid;
  gap: 6px;
  color: var(--sp-muted);
  font-size: 12px;
  min-width: 0;
}
.simple-profitability :is(input:not([type="checkbox"]), select, textarea) {
  max-width: 100%;
  min-height: 40px;
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--sp-ink);
}
.sp-summary {
  padding: 0 0 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--sp-line);
}
.sp-summary h2 {
  font-size: 24px;
  line-height: 1.3;
  margin: 0 0 10px;
  letter-spacing: -0.025em;
}
.sp-summary[data-state="profit"] h2 {
  color: #22732c;
}
.sp-summary[data-state="loss"] h2 {
  color: #ba2b32;
}
.sp-summary[data-state="missing"] h2 {
  color: var(--sp-muted);
}
.sp-summary p {
  line-height: 1.6;
  color: var(--sp-muted);
}
.sp-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin: 20px 0;
}
.sp-metric {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 0 0 16px;
  border-bottom: 2px solid var(--sp-line);
}
.sp-metric > span {
  color: var(--sp-muted);
  font-size: 12px;
  font-weight: 600;
}
.sp-metric > strong {
  color: var(--sp-ink);
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.3;
  overflow-wrap: anywhere;
  letter-spacing: -0.025em;
}
.sp-metric > small {
  color: var(--sp-muted);
  font-size: 12px;
  line-height: 1.5;
}
.sp-panel {
  padding: 0;
  margin: 28px 0;
  background: #fff;
  min-width: 0;
}
.sp-panel h2 {
  font-size: 19px;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  line-height: 1.4;
}
.sp-panel h3 {
  font-size: 15px;
  line-height: 1.4;
}
.sp-panel > p,
.sp-form-intro,
.sp-form-note {
  color: var(--sp-muted);
  line-height: 1.6;
  font-size: 13px;
}
.sp-notice {
  border-left: 3px solid var(--sp-brand);
  padding: 10px 14px;
  background: #fff;
  color: var(--sp-ink);
  line-height: 1.6;
  margin: 16px 0;
}
.sp-notice ul {
  margin: 6px 0;
  padding-left: 18px;
}
.sp-empty {
  padding: 16px 0;
  color: var(--sp-muted);
  line-height: 1.6;
}
.sp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}
.simple-profitability .table-scroll {
  max-width: 100%;
  overflow: auto;
}
.simple-profitability .table-scroll table {
  width: 100%;
  min-width: 0;
  white-space: normal;
}
.simple-profitability table :is(th, td) {
  padding: 12px 10px;
  border-bottom: 1px solid var(--sp-line);
  overflow-wrap: anywhere;
  vertical-align: top;
}
.simple-profitability table :is(th, td):first-child {
  width: auto;
}
.simple-profitability th {
  color: var(--sp-muted);
  font-size: 11px;
  font-weight: 600;
  background: #fff;
}
.simple-profitability td {
  font-size: 13px;
  line-height: 1.5;
}
.simple-profitability td small {
  display: block;
  color: var(--sp-muted);
  margin-top: 4px;
}
.sp-profile-list,
.sp-cost-list {
  display: grid;
  gap: 12px;
}
.sp-profile-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--sp-line);
}
.sp-profile-card > div {
  min-width: 0;
}
.sp-profile-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.sp-profile-card p {
  margin: 5px 0;
  line-height: 1.6;
}
.sp-profile-card small {
  color: var(--sp-muted);
}
.simple-profitability .module-status {
  border: 1px solid var(--sp-line);
  border-radius: 100px;
  padding: 4px 9px;
  background: #fff;
  color: #555;
  font-size: 11px;
}
.simple-profitability .check-field {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
}
body:has(.simple-profitability) .detail-dialog .primary {
  background: var(--sp-brand);
  border-color: var(--sp-brand);
  color: #fff;
}
body:has(.simple-profitability) .detail-dialog .primary:hover:not(:disabled) {
  background: var(--sp-blue-dark);
  border-color: var(--sp-blue-dark);
  color: #fff;
}
body:has(.simple-profitability) .detail-dialog .dialog-grid {
  gap: 14px;
}
.sp-form-intro,
.sp-form-note {
  grid-column: 1/-1;
  margin: 0 0 8px;
}
@media (max-width: 1100px) {
  .sp-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .simple-profitability {
    padding: 18px 14px;
  }
  .sp-heading {
    flex-direction: column;
    gap: 12px;
  }
  .sp-heading h1 {
    font-size: 25px;
  }
  .sp-tabs {
    gap: 6px;
  }
  .sp-tabs button {
    flex: 1 1 140px;
    padding: 10px;
  }
  .sp-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .sp-toolbar > button {
    grid-column: 1/-1;
  }
  .sp-toolbar .field {
    min-width: 0;
  }
  .sp-profile-card {
    display: grid;
  }
  .sp-metrics {
    gap: 14px;
  }
  .sp-metric > strong {
    font-size: 22px;
  }
}

.sp-panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sp-panel-heading h2 {
  margin: 0;
}
.sp-result {
  display: block;
  font-size: clamp(22px, 3.3vw, 38px);
  letter-spacing: -0.035em;
  line-height: 1.3;
}
.simple-profitability .sp-badge {
  display: inline-flex;
  width: fit-content;
  margin: 5px 0;
}
.simple-profitability .sp-badge[data-state="ready"],
.simple-profitability .sp-badge[data-state="confirmed"] {
  border-color: var(--sp-brand);
  background: var(--sp-brand);
  color: #fff;
}
.simple-profitability .sp-badge[data-state="missing"] {
  border-color: #b66812;
  background: #b66812;
  color: #fff;
}
.sp-profile-search-results {
  display: grid;
  gap: 6px;
}
.sp-profile-search-results button {
  text-align: left;
  white-space: normal;
}

@media (max-width: 600px) {
  .simple-profitability .sp-table :is(table, tbody) {
    display: block;
  }
  .simple-profitability .sp-table thead {
    display: none;
  }
  .simple-profitability .sp-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--sp-line);
  }
  .simple-profitability .sp-table td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }
  .simple-profitability .sp-table td:first-child {
    grid-column: 1/-1;
  }
  .simple-profitability .sp-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--sp-muted);
    font-size: 11px;
    line-height: 1.4;
  }
  .simple-profitability .sp-table td[data-label=""] {
    grid-column: 1/-1;
  }
  .simple-profitability .sp-table td[data-label=""]::before {
    display: none;
  }
}

body:has(.simple-profitability) .detail-dialog input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  min-height: 0;
  border: 1px solid #bfbfbf;
  border-radius: 4px;
  padding: 0;
  margin: 0;
  background: #fff;
}
body:has(.simple-profitability) .detail-dialog input[type="checkbox"]::after {
  content: "";
  width: 8px;
  height: 4px;
  margin-top: -2px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
  opacity: 0;
}
body:has(.simple-profitability) .detail-dialog input[type="checkbox"]:checked {
  background: var(--sp-brand);
  border-color: var(--sp-brand);
}
body:has(.simple-profitability) .detail-dialog input[type="checkbox"]:checked::after {
  opacity: 1;
}
body:has(.simple-profitability) .detail-dialog input[type="checkbox"]:focus-visible {
  outline: 2px solid #171717;
  outline-offset: 3px;
}

/* Company results */
.sp-dashboard {
  --sp-sales: var(--sp-brand);
  --sp-cost: #7a8dae;
  --sp-outcome: var(--sp-blue-dark);
  --sp-card: var(--sp-blue-wash);
  --sp-panel-line: #d6e4fa;
}
.sp-result-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
}
.sp-result-presets button[aria-pressed="true"] {
  border-color: var(--sp-blue-light);
  background: #dceafe;
  color: var(--sp-blue-dark);
}
.sp-result-presets button {
  border-radius: 20px;
  padding-inline: 14px;
  background: #f4f8ff;
  color: #253f68;
}
.sp-dashboard .sp-summary {
  padding: clamp(14px, 3vw, 30px);
  border: 1px solid var(--sp-panel-line);
  border-radius: 16px;
  background: var(--sp-card);
  margin-bottom: 16px;
}
.sp-result-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.sp-dashboard .sp-result-hero h2 {
  color: #162b4e;
  font-size: clamp(23px, 3.3vw, 36px);
  margin: 0 0 4px;
}
.sp-result-hero p,
.sp-result-panel-title p,
.sp-result-period p {
  font-size: 13px;
  line-height: 1.55;
  color: #4c607b;
  margin: 0;
}
.sp-result-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 16px;
  background: #e4efe7;
  color: #245339;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 11px;
}
[data-state="missing"] .sp-result-status {
  background: #f8eedb;
  color: #694213;
}
.sp-result-status button[data-result-warnings] {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #bd8635;
  background: #fffaf0;
  color: #694213;
  font-weight: 800;
}
.sp-partial-note {
  color: #694213;
  font-size: 11px;
  font-weight: 700;
  margin-inline-start: 6px;
}
.sp-dashboard .sp-metrics {
  gap: 12px;
  margin-block: 20px 14px;
}
.sp-dashboard .sp-metric {
  padding: 14px;
  border: 1px solid var(--sp-panel-line);
  border-radius: 12px;
  background: #fff;
}
.sp-dashboard .sp-metric > .sp-metric-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  font-size: 16px;
  background: #dceafe;
  color: var(--sp-sales);
}
.sp-dashboard .sp-metric strong {
  font-size: clamp(19px, 2.4vw, 29px);
  font-variant-numeric: tabular-nums;
}
.sp-dashboard [data-state="loss"] .sp-result {
  color: #9c282e;
}
.sp-result-coverage {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 13px;
  color: #4c607b;
}
.sp-result-coverage strong {
  color: #243f69;
  margin-inline-start: 4px;
}
.sp-result-periods,
.sp-result-charts {
  display: grid;
  gap: 16px;
  margin-block: 16px;
}
.sp-result-periods {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.sp-result-charts {
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
}
.sp-comparisons .sp-result-periods {
  margin-block-start: 10px;
}
.simple-profitability .sp-comparison table {
  border-collapse: collapse;
  margin-top: 12px;
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  white-space: normal;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.simple-profitability .sp-comparison :is(th, td) {
  padding: 8px 5px;
  text-align: end;
  border-top: 1px solid var(--sp-panel-line);
}
.sp-comparison th:first-child {
  text-align: start;
}
.simple-profitability .sp-comparison thead th:first-child {
  width: 29%;
}
.sp-comparison thead th:nth-child(2) {
  width: 29%;
}
.sp-comparison thead th {
  color: #4c607b;
  font-weight: 600;
}
.sp-delta {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px 18px;
}
.sp-delta > :last-child {
  font-weight: 500;
}
.sp-comparison td[data-effect="better"] {
  color: #166534;
  font-weight: 700;
}
.sp-comparison td[data-effect="worse"] {
  color: #a32730;
  font-weight: 700;
}
.sp-result-periods > :only-child {
  grid-column: 1 / -1;
}
.sp-expense-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  padding: 12px 16px;
  margin-block: 16px;
  color: var(--sp-blue-dark);
  background: var(--sp-blue-wash);
  border: 1px solid #d6e4fa;
  border-radius: 10px;
}
.sp-expense-total strong {
  font-size: 20px;
}
.sp-result-period,
.sp-result-panel {
  padding: 18px;
  border: 1px solid var(--sp-panel-line);
  border-radius: 14px;
  min-width: 0;
}
.sp-result-period h3,
.sp-result-panel-title h3 {
  margin: 0 0 4px;
  color: #162b4e;
  font-size: 17px;
}
.sp-result-period dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 13px 0 0;
}
.sp-result-period dt {
  color: #4c607b;
  font-size: 12px;
}
.sp-result-period dd {
  margin: 3px 0 0;
  color: #162b4e;
  font-weight: 700;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.sp-result-detail {
  font-size: 13px;
  margin-top: 14px;
}
.sp-result-detail summary {
  color: var(--sp-blue-dark);
  cursor: pointer;
  font-weight: 700;
}
.sp-result-issues li {
  margin-bottom: 4px;
}
.sp-result-issues {
  padding: 12px 14px;
  border: 1px solid #ead2aa;
  border-radius: 10px;
  background: #fffaf0;
}
.sp-result-issues h3 {
  margin-top: 0;
}
.sp-result-issues a {
  margin-inline-start: 4px;
  color: var(--sp-blue-dark);
  font-weight: 700;
}
.sp-result-panel > .sp-result-detail:first-child {
  margin-top: 0;
}
.sp-dashboard [data-series="revenue"] {
  --series: var(--sp-sales);
}
.sp-dashboard [data-series="cost"] {
  --series: var(--sp-cost);
}
.sp-dashboard [data-series="result"] {
  --series: var(--sp-outcome);
}
.sp-trend-legend {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  margin-block: 12px;
  font-size: 12px;
}
.sp-trend-legend span::before {
  content: "";
  width: 0.65em;
  height: 0.65em;
  display: inline-block;
  background: var(--series);
  margin-inline-end: 5px;
  border-radius: 50%;
}
.sp-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 16px);
}
.sp-chart-month {
  text-align: center;
  font-size: 12px;
  color: #4c607b;
  min-width: 0;
}
.sp-chart-columns {
  position: relative;
  display: flex;
  height: 146px;
  margin-bottom: 5px;
  background: #f1f5fd;
}
.sp-chart-columns::after {
  position: absolute;
  content: "";
  inset: var(--zero) 0 auto;
  border-top: 1px solid #8ea4c5;
  pointer-events: none;
}
.sp-chart-bar {
  position: relative;
  top: var(--top);
  width: calc(100% / 3);
  height: var(--height);
  border-radius: 3px 3px 0 0;
  background: var(--series);
  border-inline: 1px solid #f1f5fd;
  box-sizing: border-box;
}
.sp-chart-bar[data-trend-loss="true"] {
  background: #a32730;
}
.sp-chart-bar[data-present="false"] {
  border-inline: 0;
}
.sp-cost-bars {
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}
.sp-cost-bars li > div:first-child {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  margin-bottom: 4px;
}
.sp-cost-track {
  background: #dfeafb;
  border-radius: 9px;
  height: 5px;
}
.sp-cost-track i {
  display: block;
  width: var(--width);
  height: 100%;
  border-radius: inherit;
  background: var(--sp-brand);
}
@media (max-width: 760px) {
  .sp-result-charts,
  .sp-result-periods {
    grid-template-columns: minmax(0, 1fr);
  }
  .sp-dashboard .sp-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 500px) {
  .sp-toolbar .field:has(select[name="basis"]) {
    grid-column: 1 / -1;
  }
  .sp-comparison {
    padding: 12px;
  }
  .simple-profitability .sp-comparison table {
    font-size: 12px;
  }
  .sp-dashboard .sp-metric {
    padding: 10px;
  }
}
