:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #60717b;
  --line: #d9e0e4;
  --panel: #ffffff;
  --canvas: #f7f9fa;
  --teal: #0b7f79;
  --blue: #246bce;
  --amber: #b46716;
  --green: #237a4b;
  --red: #b13f36;
  --shadow: 0 18px 45px rgba(34, 48, 58, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef3f4;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  align-items: end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1480px;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.summary-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  min-width: min(680px, 100%);
}

.summary-strip div {
  border-left: 1px solid var(--line);
  padding: 16px 18px;
}

.summary-strip div:first-child {
  border-left: 0;
}

.summary-strip span,
.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.summary-strip strong {
  font-size: 1.28rem;
}

.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 360px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1480px;
}

.controls,
.chart-panel,
.tables article,
.scenario-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  align-self: start;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.control-header,
.panel-title,
.scenario-bar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.control-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.save-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.scenario-save {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
}

.primary-button {
  background: var(--teal);
  border: 1px solid #086a65;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 8px 12px;
}

.secondary-button {
  background: #ffffff;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 8px 12px;
}

.import-export {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.icon-button,
.stepper button {
  align-items: center;
  background: #eaf1f1;
  border: 1px solid #cdd9dc;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  font-weight: 800;
  height: 38px;
  justify-items: center;
  width: 38px;
}

.tabs {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  grid-template-columns: repeat(5, 1fr);
  margin: 18px 0;
  padding: 3px;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  min-height: 36px;
}

.tab.active {
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(31, 47, 57, 0.12);
  color: var(--ink);
  font-weight: 750;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label > span {
  color: #344850;
  font-size: 0.9rem;
  font-weight: 650;
}

.module-group {
  border-top: 1px solid var(--line);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  margin-top: 4px;
  padding-top: 12px;
  text-transform: uppercase;
}

.module-group:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

input,
select {
  background: #fbfcfc;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

.input-prefix,
.input-suffix {
  align-items: center;
  background: #fbfcfc;
  border: 1px solid #cbd6da;
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  overflow: hidden;
}

.input-suffix {
  grid-template-columns: 1fr auto;
}

.input-prefix span,
.input-suffix span {
  color: var(--muted);
  font-weight: 750;
  padding: 0 10px;
}

.input-prefix input,
.input-suffix input {
  border: 0;
}

.workspace {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.scenario-bar {
  padding: 20px;
}

.scenario-bar p {
  color: var(--muted);
  margin-top: 5px;
}

.stepper {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(80px, auto) 38px;
}

.stepper output {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.15rem;
  font-weight: 850;
  min-height: 38px;
  padding: 6px 12px;
  text-align: center;
}

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

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

.metric-card strong {
  font-size: 1.35rem;
}

.limited-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.limiter-now {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.limiter-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-top: 14px;
}

.limiter-item {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 7px;
  padding: 12px;
}

.limiter-item strong {
  font-size: 0.95rem;
}

.limiter-item span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.chart-panel {
  padding: 20px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.86rem;
  font-weight: 700;
  gap: 6px;
}

.legend i {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.legend .clients {
  background: var(--teal);
}

.legend .revenue {
  background: var(--blue);
}

.legend .labor {
  background: var(--amber);
}

.chart-wrap {
  margin-top: 16px;
  position: relative;
}

canvas {
  background: linear-gradient(180deg, #fbfcfc 0%, #f3f7f7 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  max-width: 100%;
  touch-action: none;
  width: 100%;
}

.chart-tooltip {
  background: rgba(23, 32, 38, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(23, 32, 38, 0.25);
  color: #ffffff;
  left: 0;
  min-width: 210px;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 3;
}

.chart-tooltip strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 7px;
}

.chart-tooltip div {
  align-items: center;
  display: flex;
  font-size: 0.82rem;
  gap: 10px;
  justify-content: space-between;
  line-height: 1.45;
}

.chart-tooltip span {
  color: rgba(255, 255, 255, 0.72);
}

.tables {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 0.9fr)) minmax(0, 1.2fr);
}

.tables article {
  min-width: 0;
  padding: 18px;
}

.table-wrap {
  margin-top: 12px;
  overflow: auto;
}

.forecast {
  max-height: 410px;
}

table {
  border-collapse: collapse;
  font-size: 0.92rem;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.good {
  color: var(--green);
  font-weight: 800;
}

.bad {
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 1100px) {
  .topbar,
  .layout,
  .tables {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .summary-strip,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-strip div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .summary-strip div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .scenario-bar {
    align-items: stretch;
    display: grid;
  }
}

@media (max-width: 460px) {
  .summary-strip,
  .metric-grid,
  .tabs {
    grid-template-columns: 1fr;
  }

  .summary-strip div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .summary-strip div:first-child {
    border-top: 0;
  }
}
