:root {
  --sheet-row-index-width: 48px;
  --sheet-col-a-width: 168px;
  --sheet-data-col-width: 100px;
  --bg: #f4efe7;
  --bg-alt: #efe6da;
  --panel: rgba(255, 252, 246, 0.86);
  --line: rgba(91, 62, 41, 0.12);
  --text: #24170f;
  --muted: #7e6758;
  --accent: #b64d1f;
  --accent-soft: #ffd1b0;
  --shadow: 0 24px 60px rgba(54, 28, 13, 0.12);
  --sheet-grid-line: #90a7d6;
  --sheet-grid-line-strong: #2b2b2b;
  --sheet-sheet-blue: #083dff;
  --sheet-label-fill: #ffe6c8;
  --sheet-soft-fill: #fff4e8;
  --sheet-yellow-fill: #fff157;
  --sheet-green-fill: #75f06f;
  --sheet-green-strong: #05f0cf;
  --sheet-cyan-fill: #20dff0;
  --sheet-orange-fill: #ff9200;
  --sheet-gray-fill: #b7b7b7;
  --sheet-active: #22a96f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 208, 171, 0.7), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 245, 201, 0.8), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, #f7f2ea 100%);
}

body.is-resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.sheet-page {
  width: 100%;
  padding: 0;
}

.sheet-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #ffffff;
}

.sheet-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid #c8d4eb;
  background: #f5f7fb;
}

.sheet-brand {
  font-size: 15px;
  font-weight: 800;
  color: #1f2b3d;
}

.sheet-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: #667085;
  font-size: 13px;
}

.sheet-sync-form {
  margin-left: auto;
}

.sheet-range-form {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-range-label {
  font-size: 12px;
  font-weight: 700;
  color: #475467;
}

.sheet-range-input {
  height: 36px;
  border: 1px solid #d8dde8;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: #344054;
  font: inherit;
  font-size: 13px;
}

.sheet-sync-button {
  height: 36px;
  border: 1px solid #d8dde8;
  border-radius: 8px;
  padding: 0 14px;
  background: linear-gradient(180deg, #fff7ea 0%, #ffe0b9 100%);
  color: #7a3f16;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.sheet-sync-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.sheet-user-chip {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #d8dde8;
  border-radius: 8px;
  background: #fff;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

.sheet-notice {
  padding: 10px 14px;
  border-bottom: 1px solid #d8dde8;
  background: #eefbf3;
  color: #106b41;
  font-size: 13px;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgba(91, 62, 41, 0.12);
  border-radius: 20px;
  background: rgba(255, 252, 246, 0.92);
  box-shadow: var(--shadow);
}

.login-eyebrow {
  margin: 0 0 8px;
  color: #8b5b3a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.login-lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-card--wide {
  width: min(680px, 100%);
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.login-label {
  font-size: 13px;
  font-weight: 700;
  color: #475467;
}

.login-input {
  height: 44px;
  border: 1px solid #d8dde8;
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: #1f2937;
  font: inherit;
}

.login-textarea {
  min-height: 120px;
  height: auto;
  padding: 12px;
  resize: vertical;
}

.login-submit {
  height: 44px;
  margin-top: 8px;
  border: 1px solid #d8dde8;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff7ea 0%, #ffe0b9 100%);
  color: #7a3f16;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.login-error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #f5c2c7;
  border-radius: 10px;
  background: #fff1f2;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

.login-success {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #b7ebc6;
  border-radius: 10px;
  background: #eefbf3;
  color: #106b41;
  font-size: 13px;
  font-weight: 700;
}

.login-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-actions__hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #d8dde8;
  border-radius: 10px;
  background: #fff;
  color: #7a3f16;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.account-setup-note {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #d8dde8;
  border-radius: 12px;
  background: #fffaf2;
  color: #5b4a3f;
  font-size: 13px;
  line-height: 1.6;
}

.account-validation {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.account-validation__item {
  padding: 14px 16px;
  border: 1px solid #d8dde8;
  border-radius: 12px;
  background: #fff;
}

.account-validation__item.is-ok {
  border-color: #b7ebc6;
  background: #eefbf3;
}

.account-validation__item.is-error {
  border-color: #f5c2c7;
  background: #fff7f7;
}

.account-validation__title {
  font-size: 14px;
  font-weight: 800;
}

.account-validation__hint {
  margin-top: 6px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
}

.account-validation__detail {
  margin-top: 8px;
  color: #8b1e26;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.login-page--setup {
  padding: 16px;
}

.login-card--setup {
  width: min(1040px, 100%);
  padding: 22px 24px;
}

.setup-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.setup-top-note {
  padding: 14px 16px;
  border: 1px solid #d8dde8;
  border-radius: 14px;
  background: #fffaf2;
  color: #5b4a3f;
  font-size: 13px;
  line-height: 1.5;
}

.setup-top-note__title {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #2d241e;
}

.setup-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.setup-pane {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(91, 62, 41, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.setup-pane__header {
  display: grid;
  gap: 6px;
}

.setup-pane__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.setup-pane__lead {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.setup-pane__body {
  display: grid;
  gap: 10px;
}

.setup-field {
  display: grid;
  gap: 6px;
}

.account-setup-note--compact {
  margin-top: 0;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
}

.login-textarea--compact {
  min-height: 96px;
  max-height: 120px;
}

.setup-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
}

.account-validation--compact {
  margin-top: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 960px) {
  .setup-header,
  .setup-form-grid,
  .account-validation--compact {
    grid-template-columns: 1fr;
  }

  .login-card--setup {
    width: min(720px, 100%);
  }
}

.sheet-formulabar {
  display: grid;
  grid-template-columns: 72px 220px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #c8d4eb;
  background: #f8fbff;
}

.sheet-name-box,
.sheet-formula-text,
.sheet-article-picker,
.sheet-inline-picker {
  height: 30px;
  border: 1px solid #c2cce2;
  border-radius: 4px;
  background: white;
  font: inherit;
}

.sheet-name-box,
.sheet-formula-text {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #344054;
}

.sheet-article-picker,
.sheet-inline-picker {
  padding: 0 10px;
}

.sheet-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 0;
  flex: 1;
  position: relative;
}

.sheet-grid-wrap {
  overflow: auto;
  max-height: calc(100vh - 130px + 180px);
  min-width: 0;
}

.sheet-image-panel {
  min-width: 0;
  width: 280px;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.sheet-image-panel__sticky {
  position: sticky;
  top: 0;
  border: 1px solid #d8e0f2;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  box-shadow: 0 14px 30px rgba(45, 75, 138, 0.12);
  overflow: hidden;
}

.sheet-image-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
}

.sheet-image-panel__meta {
  min-width: 0;
}

.sheet-image-panel__title {
  font-size: 13px;
  font-weight: 800;
  color: #17407e;
}

.sheet-image-panel__subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #667085;
  word-break: break-word;
}

.sheet-image-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid #c5d3ee;
  border-radius: 10px;
  background: #fff;
  color: #17407e;
  cursor: pointer;
  flex: 0 0 auto;
}

.sheet-image-toggle__icon {
  display: inline-block;
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.2s ease;
  transform: rotate(90deg);
}

.sheet-image-panel__link {
  display: block;
  padding: 0 14px 14px;
}

.sheet-image-panel__img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e3eaf8;
}

.sheet-image-panel.is-collapsed {
  width: 54px;
}

.sheet-image-panel.is-collapsed .sheet-image-panel__meta,
.sheet-image-panel.is-collapsed .sheet-image-panel__link {
  display: none;
}

.sheet-image-panel.is-collapsed .sheet-image-panel__header {
  justify-content: center;
  padding: 12px 8px;
}

.sheet-image-panel.is-collapsed .sheet-image-toggle__icon {
  transform: rotate(0deg);
}

.sheet-grid {
  width: max-content;
  min-width: max-content;
  border-collapse: collapse;
  table-layout: fixed;
  background: white;
}

.sheet-grid th,
.sheet-grid td {
  border: 1px solid var(--sheet-grid-line);
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.05;
  min-width: 100px;
  height: 17px;
  text-align: center;
  vertical-align: middle;
}

.sheet-grid .corner-cell,
.sheet-grid .column-letter,
.sheet-grid .row-number {
  position: sticky;
  z-index: 3;
  background: #f7f9fd;
  color: #4a5b78;
  font-weight: 700;
}

.sheet-grid .corner-cell {
  left: 0;
  top: 0;
  min-width: var(--sheet-row-index-width);
  max-width: var(--sheet-row-index-width);
  width: var(--sheet-row-index-width);
  border-right: 1px solid var(--sheet-grid-line-strong);
}

.sheet-grid .column-letter {
  top: 0;
  border-bottom: 1px solid var(--sheet-grid-line-strong);
}

.sheet-grid .row-number {
  left: 0;
  min-width: var(--sheet-row-index-width);
  max-width: var(--sheet-row-index-width);
  width: var(--sheet-row-index-width);
  border-right: 1px solid var(--sheet-grid-line-strong);
}

.sheet-grid .col-a,
.sheet-grid .sheet-article-cell,
.sheet-grid .metric-label-cell {
  position: sticky;
  left: var(--sheet-row-index-width);
  z-index: 2;
  min-width: var(--sheet-col-a-width);
  max-width: var(--sheet-col-a-width);
  width: var(--sheet-col-a-width);
  text-align: left;
  border-right: 2px solid var(--sheet-grid-line-strong);
}

.sheet-grid .col-a {
  top: 0;
  z-index: 4;
  background: #f7f9fd;
}

.sheet-article-cell,
.metric-label-cell {
  background: var(--sheet-label-fill);
  font-weight: 700;
}

.sheet-inline-section-toggle {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 1px solid #9aaed8;
  border-radius: 4px;
  padding: 0;
  background: #ffffff;
  color: #28457a;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.sheet-inline-section-toggle:hover {
  background: #eef4ff;
}

.hide-rows-26-36 .sheet-grid tr.is-toggle-group-26-36 {
  display: none;
}

.date-header-cell {
  position: relative;
  background: var(--sheet-sheet-blue);
  color: white;
  font-weight: 800;
  border-bottom: 2px solid var(--sheet-grid-line-strong);
}

.metric-value-cell {
  background: white;
  color: #111111;
}

.sheet-grid .column-letter,
.sheet-grid .date-header-cell,
.sheet-grid .metric-value-cell {
  min-width: var(--sheet-data-col-width);
  max-width: var(--sheet-data-col-width);
  width: var(--sheet-data-col-width);
}

.sheet-col-resizer {
  position: absolute;
  top: -1px;
  right: -5px;
  width: 10px;
  height: calc(100% + 2px);
  cursor: col-resize;
  z-index: 8;
}

.sheet-col-resizer::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 2px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.sheet-grid .column-letter .sheet-col-resizer::after {
  background: rgba(74, 91, 120, 0.5);
}

.sheet-grid .column-letter:hover .sheet-col-resizer::after,
.sheet-grid .date-header-cell:hover .sheet-col-resizer::after,
body.is-resizing-columns .sheet-col-resizer::after {
  opacity: 1;
}

.sheet-cell-button {
  width: 100%;
  min-height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  font-weight: inherit;
}

.sheet-preview-input {
  display: block;
  width: 100%;
  min-height: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: center;
  outline: none;
}

.sheet-preview-input:focus {
  background: rgba(255, 255, 255, 0.14);
}

.sheet-preview-input.is-saving {
  background: rgba(255, 241, 118, 0.45);
}

.sheet-preview-input.is-error {
  background: rgba(255, 114, 94, 0.28);
}

.sheet-strategy-input {
  width: 100%;
  min-height: var(--sheet-strategy-height, 42px);
  height: var(--sheet-strategy-height, 42px);
  padding: 3px 8px;
  border: 0;
  resize: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  outline: none;
}

.sheet-strategy-input:focus {
  background: rgba(255, 255, 255, 0.3);
}

.sheet-strategy-input.is-saving {
  background: rgba(255, 241, 118, 0.45);
}

.sheet-strategy-input.is-saved {
  background: rgba(117, 240, 111, 0.35);
}

.sheet-strategy-input.is-error {
  background: rgba(255, 114, 94, 0.28);
}

.metric-label-cell--strategy {
  position: relative;
  padding-right: 16px;
}

.sheet-row-resizer {
  position: absolute;
  top: 4px;
  right: 2px;
  width: 10px;
  height: calc(100% - 8px);
  cursor: row-resize;
  z-index: 8;
}

.sheet-row-resizer::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 999px;
  background: rgba(74, 91, 120, 0.35);
  opacity: 0.7;
}

.metric-label-cell--strategy:hover .sheet-row-resizer::after,
body.is-resizing-strategy-row .sheet-row-resizer::after {
  opacity: 1;
  background: rgba(34, 102, 255, 0.55);
}

.sheet-cell-button.is-active {
  outline: 2px solid var(--sheet-active);
  outline-offset: -2px;
  border-radius: 2px;
  background: rgba(34, 169, 111, 0.1);
  font-weight: 800;
}

.is-selected {
  box-shadow: inset 0 0 0 2px #21a366;
}

.metric-row--4 .metric-value-cell,
.metric-row--7 .metric-value-cell,
.metric-row--8 .metric-value-cell,
.metric-row--9 .metric-value-cell,
.metric-row--10 .metric-value-cell,
.metric-row--11 .metric-value-cell,
.metric-row--12 .metric-value-cell,
.metric-row--13 .metric-value-cell,
.metric-row--15 .metric-value-cell,
.metric-row--16 .metric-value-cell,
.metric-row--20 .metric-value-cell,
.metric-row--25 .metric-value-cell,
.metric-row--26 .metric-value-cell,
.metric-row--27 .metric-value-cell,
.metric-row--28 .metric-value-cell,
.metric-row--29 .metric-value-cell,
.metric-row--30 .metric-value-cell,
.metric-row--31 .metric-value-cell,
.metric-row--32 .metric-value-cell,
.metric-row--33 .metric-value-cell,
.metric-row--34 .metric-value-cell,
.metric-row--35 .metric-value-cell,
.metric-row--36 .metric-value-cell,
.metric-row--52 .metric-value-cell,
.metric-row--53 .metric-value-cell,
.metric-row--54 .metric-value-cell,
.metric-row--55 .metric-value-cell,
.metric-row--56 .metric-value-cell,
.metric-row--57 .metric-value-cell {
  background: var(--sheet-soft-fill);
}

.metric-row--5 .metric-value-cell,
.metric-row--14 .metric-value-cell,
.metric-row--39 .metric-value-cell,
.metric-row--46 .metric-value-cell {
  background: var(--sheet-yellow-fill);
}

.metric-value-cell.metric-value-cell--drr-low {
  background: #00ff40;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--drr-mid {
  background: #fff157;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--drr-mid-high {
  background: #ff9900;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--drr-high {
  background: #ff0000;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--margin-negative {
  background: #ff0000;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--margin-low {
  background: #ff9900;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--margin-mid {
  background: #fff157;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--margin-high {
  background: #00ff40;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--net-negative {
  background: #ff0000;
  color: #111111;
  font-weight: 800;
}

.metric-value-cell.metric-value-cell--net-positive {
  background: #8cff66;
  color: #111111;
  font-weight: 800;
}

.metric-row--6 .metric-value-cell {
  background: #18f0f3;
  font-weight: 700;
}

.metric-row--8 .metric-value-cell {
  background: #ff00c8;
  color: #111111;
  font-weight: 700;
}

.metric-row--6 .metric-label-cell,
.metric-row--8 .metric-label-cell,
.metric-row--12 .metric-label-cell {
  font-weight: 800;
}

.metric-row--6 .metric-value-cell,
.metric-row--18 .metric-value-cell {
  font-size: 13px;
}

.metric-row--12 .metric-value-cell {
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--payback-low {
  background: #ff1f1f;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--payback-mid-low {
  background: #fff157;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--payback-mid {
  background: #c6e2b5;
  color: #111111;
  font-weight: 700;
}

.metric-value-cell.metric-value-cell--payback-high {
  background: #28f428;
  color: #111111;
  font-weight: 700;
}

.metric-row--19 .metric-value-cell,
.metric-row--37 .metric-value-cell,
.metric-row--44 .metric-value-cell,
.metric-row--58 .metric-value-cell {
  background: var(--sheet-cyan-fill);
}

.metric-row--19 .metric-value-cell {
  padding: 0;
  vertical-align: top;
}

.metric-row--20 .metric-label-cell,
.metric-row--21 .metric-label-cell,
.metric-row--22 .metric-label-cell,
.metric-row--23 .metric-label-cell,
.metric-row--24 .metric-label-cell,
.metric-row--40 .metric-label-cell,
.metric-row--41 .metric-label-cell,
.metric-row--42 .metric-label-cell,
.metric-row--43 .metric-label-cell,
.metric-row--47 .metric-label-cell,
.metric-row--48 .metric-label-cell,
.metric-row--49 .metric-label-cell,
.metric-row--50 .metric-label-cell,
.metric-row--51 .metric-label-cell {
  background: #fff6ef;
}

.metric-row--20 .metric-value-cell,
.metric-row--21 .metric-value-cell,
.metric-row--22 .metric-value-cell,
.metric-row--23 .metric-value-cell {
  background: #ffb347;
}

.metric-row--40 .metric-value-cell,
.metric-row--41 .metric-value-cell,
.metric-row--42 .metric-value-cell,
.metric-row--43 .metric-value-cell,
.metric-row--47 .metric-value-cell,
.metric-row--48 .metric-value-cell,
.metric-row--49 .metric-value-cell,
.metric-row--50 .metric-value-cell,
.metric-row--51 .metric-value-cell {
  background: var(--sheet-orange-fill);
}

.metric-row--19 .metric-label-cell,
.metric-row--37 .metric-label-cell,
.metric-row--44 .metric-label-cell {
  background: var(--sheet-gray-fill);
}

.metric-row--20 .metric-label-cell,
.metric-row--21 .metric-label-cell,
.metric-row--22 .metric-label-cell,
.metric-row--23 .metric-label-cell {
  background: var(--sheet-label-fill);
  font-weight: 700;
}

.metric-row--20 .metric-value-cell,
.metric-row--21 .metric-value-cell,
.metric-row--22 .metric-value-cell,
.metric-row--23 .metric-value-cell {
  background: #ffffff;
  color: #111111;
  font-weight: 400;
}

.sheet-grid tbody tr[data-display-row="44"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="45"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="46"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="47"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="51"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="52"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="53"] > .metric-label-cell,
.sheet-grid tbody tr[data-display-row="54"] > .metric-label-cell {
  background: var(--sheet-label-fill);
  font-weight: 700;
}

.sheet-grid tbody tr[data-display-row="44"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="45"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="46"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="47"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="51"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="52"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="53"] > .metric-value-cell,
.sheet-grid tbody tr[data-display-row="54"] > .metric-value-cell {
  background: #ffffff;
  color: #111111;
  font-weight: 400;
}

.sheet-grid tbody tr[data-display-row="43"] > .metric-value-cell.metric-value-cell--drr-low,
.sheet-grid tbody tr[data-display-row="50"] > .metric-value-cell.metric-value-cell--drr-low {
  background: #80ff9f;
}

.sheet-grid tbody tr[data-display-row="43"] > .metric-value-cell.metric-value-cell--drr-mid,
.sheet-grid tbody tr[data-display-row="50"] > .metric-value-cell.metric-value-cell--drr-mid {
  background: #fff8ab;
}

.sheet-grid tbody tr[data-display-row="43"] > .metric-value-cell.metric-value-cell--drr-mid-high,
.sheet-grid tbody tr[data-display-row="50"] > .metric-value-cell.metric-value-cell--drr-mid-high {
  background: #ffcc80;
}

.sheet-grid tbody tr[data-display-row="43"] > .metric-value-cell.metric-value-cell--drr-high,
.sheet-grid tbody tr[data-display-row="50"] > .metric-value-cell.metric-value-cell--drr-high {
  background: #ff8080;
}

.sheet-grid tbody tr[data-display-row="41"] > td,
.sheet-grid tbody tr[data-display-row="48"] > td,
.sheet-grid tbody tr[data-display-row="55"] > td {
  border-top: 2px solid #000000;
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 244, 233, 0.78)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero--compact {
  align-items: start;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.hero h1,
.panel h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(32px, 4vw, 58px);
  line-height: 0.98;
}

.hero__lead {
  max-width: 680px;
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}

.hero__stats,
.summary-grid,
.metric-grid {
  display: grid;
  gap: 14px;
}

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

.summary-grid {
  margin-top: 20px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card,
.summary-tile,
.metric-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
}

.stat-card__label,
.summary-tile span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong,
.summary-tile strong,
.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.panel {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel__header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

.search-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-form--inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-form input,
.search-form select,
.search-form button {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
}

.search-form input,
.search-form select {
  min-width: 220px;
  background: rgba(255, 255, 255, 0.92);
}

.search-form button {
  background: linear-gradient(135deg, var(--accent) 0%, #d65e20 100%);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: rgba(255, 255, 255, 0.74);
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.data-table a,
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

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

.sheet-toolbar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-group select {
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.92);
}

.table-wrap--sheet {
  max-height: 72vh;
}

.data-table--sheet {
  min-width: 1800px;
  table-layout: fixed;
}

.data-table--sheet th,
.data-table--sheet td {
  font-size: 13px;
  padding: 10px 12px;
}

.sheet-col-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 280px;
  max-width: 280px;
  background: #fbf5eb;
  font-weight: 800;
}

.data-table--sheet thead .sheet-col-label {
  z-index: 4;
}

.data-table--sheet td.is-selected,
.data-table--sheet th.is-selected {
  background: rgba(255, 209, 176, 0.45);
}

.base-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.base-tab {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.base-tab.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #d65e20 100%);
  color: white;
  border-color: transparent;
}

.base-filters {
  margin-bottom: 14px;
}

.base-summary {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.data-table--base {
  min-width: 1200px;
}

.data-table--base td {
  font-size: 13px;
  vertical-align: top;
 }

.data-table--base-workgrid {
  min-width: auto;
  border-collapse: collapse;
}

.data-table--base-workgrid th,
.data-table--base-workgrid td {
  padding: 6px 8px;
  border: 1px solid #cfd7e6;
  background: #ffffff;
  vertical-align: middle;
}

.data-table--base-workgrid th {
  background: #eef3fb;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.data-table--base-workgrid td {
  font-size: 12px;
  color: #111827;
}

.data-table--base-costs {
  table-layout: fixed;
}

.data-table--base-costs th,
.data-table--base-costs td {
  padding: 5px 6px;
}

.data-table--base-costs th {
  font-size: 10px;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
  min-width: 82px;
}

.data-table--base-costs td {
  font-size: 11px;
  white-space: nowrap;
}

.cost-column-letters-row th {
  padding: 4px 6px;
  background: #dfe7f5;
  color: #53637e;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.cost-column-letter {
  letter-spacing: 0.04em;
}

.cost-column-header__main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.data-table--base-compact th,
.data-table--base-compact td {
  padding: 7px 10px;
  line-height: 1;
}

.base-edit-input {
  width: 100%;
  min-width: 88px;
  border: 1px solid #cfd7e6;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  color: #1f2937;
  background: #fffef9;
}

.base-edit-input--cell {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.base-edit-input--compact {
  min-width: 72px;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1;
}

.base-edit-input:focus {
  outline: none;
  border-color: #5c7cfa;
  box-shadow: 0 0 0 2px rgba(92, 124, 250, 0.18);
}

.base-edit-input.is-saved {
  border-color: #12b886;
  background: #eefcf6;
}

.base-edit-input.is-error {
  border-color: #e03131;
  background: #fff5f5;
}

.base-global-settings {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.base-global-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

#save-global-cost-settings {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid #d16a2e;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffcc8f 0%, #ef9b47 100%);
  color: #6a2f0a;
  font-weight: 800;
  box-shadow: 0 2px 0 rgba(140, 69, 17, 0.18);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

#save-global-cost-settings:hover {
  filter: brightness(1.02);
  box-shadow: 0 4px 10px rgba(140, 69, 17, 0.16);
}

#save-global-cost-settings:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(140, 69, 17, 0.14);
}

#save-global-cost-settings:disabled {
  opacity: 0.7;
  cursor: wait;
}

.toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 14px;
  border: 1px solid rgba(197, 91, 20, 0.22);
  background: linear-gradient(135deg, #ef7b22, #c55b14);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(197, 91, 20, 0.18);
}

.toolbar-button--secondary {
  background: linear-gradient(135deg, #fff4dd, #ffd6a3);
  color: #8b4a12;
  border-color: rgba(197, 91, 20, 0.18);
  box-shadow: none;
}

.notice-banner {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(239, 123, 34, 0.08);
  border: 1px solid rgba(197, 91, 20, 0.18);
  color: #6c3511;
  font-weight: 600;
}

.matrix-report-wrap {
  overflow: auto;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

.net-profit-page {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

body.is-resizing-net-profit-columns {
  cursor: col-resize;
  user-select: none;
}

.matrix-report-table {
  width: max-content;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
}

.matrix-report-table th,
.matrix-report-table td {
  border: 1px solid #c8d4eb;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.05;
  text-align: right;
  white-space: nowrap;
}

.matrix-report-date,
.matrix-report-value {
  width: var(--net-profit-col-width, 54px);
  min-width: var(--net-profit-col-width, 54px);
  max-width: var(--net-profit-col-width, 54px);
  padding-left: 6px;
  padding-right: 6px;
}

.matrix-report-date {
  text-align: center;
}

.matrix-report-col-resizer {
  position: absolute;
  top: -1px;
  right: -5px;
  width: 10px;
  height: calc(100% + 2px);
  cursor: col-resize;
  z-index: 8;
}

.matrix-report-col-resizer::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 2px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.matrix-report-date:hover .matrix-report-col-resizer::after,
body.is-resizing-net-profit-columns .matrix-report-col-resizer::after {
  opacity: 1;
}

.matrix-report-value.is-positive {
  background: #c9f7b5;
  color: #111111;
  font-weight: 700;
}

.matrix-report-value.is-negative {
  background: #ffb3b3;
  color: #111111;
  font-weight: 700;
}

.matrix-report-date__main,
.matrix-report-date__sub {
  display: block;
}

.matrix-report-date__main {
  font-size: 11px;
  line-height: 1;
}

.matrix-report-date__sub {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1;
  opacity: 0.82;
}

.matrix-report-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0b4dff;
  color: #fff;
  font-weight: 800;
}

.matrix-report-table thead th:first-child,
.matrix-report-table .matrix-report-article {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: #fff4e8;
  font-weight: 700;
}

.matrix-report-corner,
.matrix-report-article {
  width: 82px;
  min-width: 82px;
  max-width: 82px;
  padding-left: 8px;
  padding-right: 8px;
}

.matrix-report-table thead th:first-child {
  z-index: 3;
}

.matrix-report-total-row td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -2px 0 rgba(11, 77, 255, 0.12);
}

.matrix-report-total-row .matrix-report-article {
  z-index: 3;
}

.matrix-report-total-row td {
  background: #fff0c7;
  font-weight: 800;
}

@media (max-width: 980px) {
  :root {
    --sheet-col-a-width: 180px;
  }

  .sheet-formulabar {
    grid-template-columns: 1fr;
  }

  .sheet-range-form {
    width: 100%;
    justify-content: flex-end;
  }

  .sheet-meta {
    display: none;
  }

  .sheet-workspace {
    grid-template-columns: 1fr;
  }

  .sheet-image-panel {
    width: 100%;
  }

  .sheet-image-panel.is-collapsed {
    width: 100%;
  }

  .sheet-image-panel__sticky {
    position: static;
  }

  .hero,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .panel__header {
    align-items: start;
    flex-direction: column;
  }

  .sheet-col-label {
    min-width: 220px;
    max-width: 220px;
  }
}
