:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #f0f4f2;
  --ink: #17201e;
  --muted: #64716d;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-2: #b45309;
  --accent-3: #335c81;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(23, 32, 30, 0.065);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

input {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  align-items: stretch;
  gap: 22px;
  padding: 16px clamp(18px, 4vw, 42px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 172px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
}

.brand-description {
  max-width: 30ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 2vw, 2.05rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 22px;
  padding: 22px clamp(18px, 4vw, 42px) 38px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding-right: 2px;
}

.control-section,
.chart-panel,
.schedule-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-section {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.field-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.duration-hint {
  display: block;
  margin-top: -1px;
  color: var(--accent-3);
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.25;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd6d1;
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

input:read-only {
  cursor: default;
}

input {
  height: 42px;
  padding: 0 11px;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.input-suffix,
.input-prefix {
  display: grid;
  align-items: center;
  border: 1px solid #cbd6d1;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

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

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

.input-suffix:focus-within,
.input-prefix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.input-suffix input,
.input-prefix input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.input-suffix span,
.input-prefix span {
  min-width: 42px;
  padding: 0 10px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.input-suffix span {
  border-left: 1px solid var(--line);
}

.input-prefix span {
  border-right: 1px solid var(--line);
}

.field-disabled {
  opacity: 0.58;
}

.field-disabled input {
  background: #f3f5f4;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.segmented label {
  display: block;
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  min-width: 86px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-align: center;
}

.segmented input:checked + span {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 32, 30, 0.08);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

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

.kpi {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  min-height: 82px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi span,
.kpi small,
.chart-head span,
#scheduleMeta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.kpi strong {
  align-self: end;
  min-width: 0;
  color: var(--ink);
  font-size: clamp(1.08rem, 1.45vw, 1.45rem);
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.kpi.negative strong {
  color: var(--danger);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-panel {
  min-width: 0;
  padding: 16px;
}

.chart-panel.wide {
  grid-column: 1 / -1;
}

.chart-head,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}

.mode-status,
.currency-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #b9d8d3;
  border-radius: 999px;
  color: #0b625b;
  background: #edf8f6;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.mode-status.manual {
  color: #8a4b08;
  background: #fff7ed;
  border-color: #f0cda7;
}

.currency-label {
  color: var(--muted);
  background: #f5f7f6;
  border-color: var(--line);
  letter-spacing: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
  border-radius: 8px;
  background: #fbfcfb;
  border: 1px solid #eef2f0;
}

.schedule-section {
  min-width: 0;
  padding: 16px;
}

.table-wrap {
  max-height: 540px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf1ef;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f6f9f7;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

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

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 112px;
  min-width: 112px;
  background: #ffffff;
}

th:nth-child(2),
td:nth-child(2) {
  position: sticky;
  left: 112px;
  z-index: 2;
  width: 138px;
  min-width: 138px;
  background: #ffffff;
  box-shadow: 8px 0 12px -12px rgba(23, 32, 30, 0.72);
}

th:first-child,
th:nth-child(2) {
  z-index: 5;
  background: #f6f9f7;
}

td input {
  width: 112px;
  height: 34px;
  text-align: right;
  padding: 0 8px;
}

.deploy-input[readonly] {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  pointer-events: none;
}

.deploy-input:not([readonly]) {
  border-color: #9fc9c2;
  background: #f8fffd;
}

td.cash-negative {
  color: var(--danger);
  font-weight: 760;
}

.methodology {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) minmax(0, 2fr);
  gap: 28px;
  padding: 22px 4px 8px;
  border-top: 1px solid var(--line);
}

.methodology-heading h2 {
  margin-top: 4px;
  font-size: 1.15rem;
}

.methodology-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
}

.methodology-grid div {
  min-width: 0;
}

.methodology-grid dt {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.methodology-grid dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.site-footer {
  padding: 0 clamp(18px, 4vw, 42px) 32px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

@media (min-width: 1600px) {
  .kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .brand {
    min-height: 82px;
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
  }

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

  .controls {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .brand {
    min-height: auto;
    padding: 8px 0 2px;
  }

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

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

@media (max-width: 620px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi {
    min-height: 108px;
    padding: 12px;
  }

  .kpi strong {
    font-size: 1.08rem;
  }

  .section-head,
  .chart-head,
  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .section-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .methodology-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .site-footer {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
