/* Finance Plan screen. Colors, type and spacing come from styles.css. */
body.plan {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--color-page);
  font-size: var(--text-sm);
}

.plan-header {
  flex: none;
  flex-wrap: wrap;
}

.plan-header .wordmark {
  position: static;
  transform: none;
}

.plan-name {
  font-size: var(--text-md);
  font-weight: 600;
  white-space: nowrap;
}

.plan-status {
  margin: 0 0 0 auto;
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
}

.plan-header .sheet-tabs {
  margin-left: var(--space-3);
}

.sheet-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
  background: var(--color-page);
}

.sheet-surface {
  position: relative;
}

.typing-catcher {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
}

/* Cells, in the manner of a Numbers table */
.sheet-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.sheet-table td {
  position: relative;
  padding: 0 var(--space-2);
  overflow: hidden;
  vertical-align: middle;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: cell;
}

.sheet-table td.is-frozen {
  position: sticky;
  background-color: var(--color-page);
}

.sheet-table td.overflow {
  overflow: visible;
}

.sheet-table td.align-right {
  text-align: right;
}

.sheet-table td.align-center {
  text-align: center;
}

.sheet-table td.cell--title {
  font-family: var(--font-display);
  font-size: var(--text-sheet-title);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
}

.sheet-table td.cell--section {
  padding-bottom: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-section);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  vertical-align: bottom;
}

.sheet-table td.cell--group {
  background-color: var(--color-header);
  font-weight: 600;
}

.sheet-table td.cell--header {
  border-bottom: 1px solid var(--color-line-strong);
  background-color: var(--color-sunken);
  color: var(--color-ink);
  font-size: var(--text-xs);
  font-weight: 500;
}

.sheet-table td.cell--label {
  border-bottom: 1px solid var(--color-line);
  background-color: var(--color-surface);
}

.sheet-table td.cell--planned {
  color: var(--color-accent-text);
}

/* A blue tint can be edited. Plain white is calculated. */
.sheet-table td.is-editable {
  border-right: 2px solid var(--color-surface);
  border-bottom: 2px solid var(--color-surface);
  background-color: var(--color-editable);
  cursor: text;
  transition: background-color var(--motion);
}

.sheet-table td.is-editable:hover {
  background-color: var(--color-editable-hover);
}

.sheet-table td.is-auto {
  border-bottom: 1px solid var(--color-line);
  background-color: var(--color-surface);
  cursor: default;
}

.sheet-table td.cell--computed {
  border-bottom: 1px solid var(--color-line);
  background-color: var(--color-surface);
  font-weight: 500;
}

.sheet-table td.cell--row-total {
  background-color: var(--color-auto);
  font-weight: 600;
}

.sheet-table td.cell--total-label,
.sheet-table td.cell--grand-total {
  border-top: 1px solid var(--color-accent);
  background-color: var(--color-auto);
  font-weight: 600;
}

/* A table shown inside a card, as on the Planning tab */
.sheet-card-scroll {
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.plan-card-note.sheet-card-note {
  margin: 0 0 var(--space-3);
}

.sheet-table.is-card td.is-frozen,
.sheet-table.is-card td.cell--blank {
  background-color: var(--color-surface);
}

.sheet-table.is-card td.cell--group.is-frozen,
.sheet-table.is-card td.cell--header.is-frozen {
  background-color: var(--color-header);
}

.sheet-table.is-card td.is-editable.is-frozen {
  background-color: var(--color-editable);
}

.sheet-table.is-card td.is-editable.is-frozen:hover {
  background-color: var(--color-editable-hover);
}

.sheet-table.is-card td.is-top-total.is-frozen {
  background-color: var(--color-auto);
}

.sheet-table.is-card td.plan-row-action {
  padding: 0;
  text-align: center;
  cursor: default;
}

/* Revenue: the total row stays at the top */
.sheet-table td.is-top-total-end {
  border-bottom: 2px solid var(--color-accent);
}

.sheet-table td.is-top-total {
  border-top: 0;
  background-color: var(--color-auto);
  font-size: var(--text-md);
  font-weight: 600;
}

.sheet-table.is-card td.is-top-total.is-total-name {
  padding-right: var(--space-3);
  border-top: 0;
  border-bottom: 0;
  background-color: var(--color-surface);
  color: var(--color-ink-muted);
  font-size: var(--text-sm);
  text-align: right;
}

.sheet-table.is-card td.is-top-total.is-total-name.is-stopped {
  color: var(--color-ink);
  text-align: left;
}

/* Lines that separate months and the frozen columns */
.sheet-table td.is-group-start {
  border-left: 1px solid var(--color-line-strong);
}

.sheet-table td.is-frozen-edge {
  border-right: 1px solid var(--color-line-strong);
}

/* Project status: a colored dot beside the name */
.sheet-table td[data-status] > div::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--color-ink-muted);
}

.sheet-table td[data-status="accured-revenue"] > div::before {
  background: var(--color-status-accrued);
}

.sheet-table td[data-status="accounts-receivable"] > div::before {
  background: var(--color-accent);
}

.sheet-table td[data-status="cash-received"] > div::before {
  background: var(--color-good);
}

.sheet-table td[data-status="cash-handed"] > div::before {
  background: var(--color-status-handed);
}

.sheet-table td[data-status="cancelled"] > div::before {
  background: var(--color-bad);
}

/* Status: a small rounded badge */
.sheet-table td.is-pass,
.sheet-table td.is-fail {
  font-weight: 500;
  text-align: center;
}

.sheet-table td.is-pass > div,
.sheet-table td.is-fail > div {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

.sheet-table td.is-pass > div {
  background: var(--color-good-soft);
  color: var(--color-good);
}

.sheet-table td.is-fail > div {
  background: var(--color-bad-soft);
  color: var(--color-bad);
}

.sheet-table td.is-selected {
  box-shadow: inset 0 0 0 2px var(--color-accent);
}

.sheet-table td.has-list {
  padding-right: 20px;
}

.sheet-table td.has-list::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--space-2);
  width: 6px;
  height: 6px;
  margin-top: -5px;
  border-right: 1.5px solid var(--color-line-strong);
  border-bottom: 1.5px solid var(--color-line-strong);
  transform: rotate(45deg);
}

.sheet-table td.has-note::before {
  content: "";
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
}

.cell-editor {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0 var(--space-2);
  border: 0;
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  background: var(--color-surface);
  color: var(--color-ink);
  font: inherit;
  font-weight: 400;
  text-align: left;
}

/* Charts */
.chart-frame {
  position: absolute;
  z-index: 1;
  width: 998px;
  height: 390px;
  overflow: hidden;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-rest);
}

.chart-frame svg {
  display: block;
}

.chart-title {
  fill: var(--color-ink);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chart-text {
  fill: var(--color-ink-muted);
  font-size: var(--text-xs);
}

.chart-legend {
  fill: var(--color-ink);
  font-size: var(--text-sm);
}

.chart-value {
  fill: var(--color-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  stroke: var(--color-surface);
  stroke-width: 3px;
  paint-order: stroke;
}

.chart-grid {
  stroke: var(--color-sunken);
}

.chart-baseline {
  stroke: var(--color-line-strong);
}

.chart-cursor {
  stroke: var(--color-ink-muted);
  stroke-dasharray: 3 3;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-raised);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  font-weight: 600;
}

.chart-tooltip i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
}

/* On a phone the frozen columns would fill the screen, so everything scrolls */
@media (max-width: 700px) {
  .sheet-table td.is-frozen {
    position: relative;
    top: auto !important;
    left: auto !important;
  }

  .sheet-scroll {
    scroll-padding: 0 !important;
  }
}

/* Month cells: a calendar icon to pick the month */
.sheet-table td.has-date {
  padding-right: 30px;
}

.sheet-date-button {
  position: absolute;
  top: 50%;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-accent-text);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--motion), background-color var(--motion);
}

.sheet-table td:hover .sheet-date-button,
.sheet-table td.is-selected .sheet-date-button,
.sheet-date-button:focus-visible {
  opacity: 1;
}

.sheet-date-button:hover {
  background: var(--color-editable-hover);
}

.sheet-date-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
