/* Page 2 - Operations: avenues, the work board, AI usage, expenses (SPEC-STEP7 6.2).
   The page is built from the shared parts in app.css (Tabs, Figures, FilterRow, DataTable,
   Board, Pill, Due, Sheet). This file holds only what they do not give: the plain lines
   inside an avenue's "Features and bugs" and in sheets, the AI budget warning line, the
   daily chart, and a few pieces of the sheets and the CSV upload.

   Every stylesheet is global, so every selector here carries an ops- class. Colours, sizes
   and the font come from the tokens in app.css only. */

/* ---------- The numbers line ---------- */

/* A wrapper that leaves the shared numbers line as it is (display: contents), except on the
   narrowest phones, where four labels such as "Subscriptions" do not fit side by side
   without breaking a word: there the numbers sit two by two. */
.ops-figs {
  display: contents;
}

@media (max-width: 359px) {
  .ops-figs dl.figures {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }
}

/* ---------- Plain lines: features and bugs, work in a sheet, costs of an avenue ---------- */

.ops-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ops-line + .ops-line {
  border-top: 1px solid var(--line-soft);
}

/* Title and the quiet line on the left; priority, due date and owner on the right. */
.ops-line__open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title end"
    "sub end";
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

button.ops-line__open {
  cursor: pointer;
}

.ops-line__title {
  grid-area: title;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
}

.ops-line__sub {
  grid-area: sub;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 18px;
}

.ops-line__sub--wrap {
  white-space: normal;
}

.ops-line__end {
  grid-area: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 13px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ops-line.is-quiet .ops-line__title,
.ops-line.is-quiet .ops-line__sub--wrap {
  white-space: normal;
}

.ops-line__end {
  color: var(--ink-3);
}

@media (hover: hover) {
  button.ops-line__open:hover .ops-line__title {
    color: var(--link);
  }
}

/* On a narrow phone the owner's mark gives its room to the date (as on the board). */
@media (max-width: 420px) {
  .ops-line__end .mark {
    display: none;
  }
}

/* ---------- Avenues: the "Features and bugs" button and its panel ---------- */

/* A quiet text button in its cell; on phones it is the row's third line. */
.ops-tracked__toggle {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-size: 13px;
  line-height: 18px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.ops-tracked__toggle[aria-expanded="true"] {
  font-weight: 600;
}

@media (hover: hover) {
  .ops-tracked__toggle:hover {
    text-decoration: underline;
  }
}

@media (max-width: 899px) {
  /* A 44px tap area that does not make the row taller than it needs to be. */
  .ops-tracked__toggle {
    min-height: var(--tap);
    margin: -10px 0 -10px;
  }
}

.ops-tracked {
  display: grid;
  gap: 12px;
  max-width: 760px;
}

.ops-tracked__group {
  display: grid;
  gap: 2px;
}

.ops-tracked__head {
  margin: 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.ops-tracked__n {
  font-weight: 400;
}

.ops-tracked__empty {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 18px;
}

.ops-tracked__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ops-tracked__add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* ---------- Work board ---------- */

/* Drag and drop on laptops. */

.ops-board .board__col.is-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.ops-board .bcard[draggable="true"] {
  cursor: grab;
}

.ops-board .bcard.is-dragging {
  opacity: 0.5;
}

/* The priority filter: a small select among the filter row's actions. */
.ops-select__input {
  width: auto;
  min-height: 32px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 13px;
}

@media (max-width: 899px) {
  .ops-select__input {
    min-height: var(--tap);
    font-size: 16px;
  }
}

/* ---------- AI usage ---------- */

/* The one warning line, only while the warning level or the budget is passed. */
.ops-warnline {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-control);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.ops-usage {
  display: grid;
  gap: 12px;
  padding-bottom: 28px;
}

.ops-usage__switch {
  display: flex;
  margin-top: 12px;
}

.ops-none,
.ops-note {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 18px;
}

.ops-none {
  padding: 16px 0;
}

.ops-provider {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ops-margin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ops-nowrap {
  white-space: nowrap;
}

/* Words that name a number where there are no column headings: phones only. */
.ops-phoneword {
  display: inline;
}

.ops-laptopword {
  display: none;
}

@media (min-width: 900px) {
  .ops-phoneword {
    display: none;
  }

  .ops-laptopword {
    display: inline;
  }
}

/* ---------- AI usage: the daily chart ---------- */

/* Providers: the accent blue, a lighter blue, grey, then a hatched fourth for the rest. */
.ops-series-1 {
  background: var(--accent);
  fill: var(--accent);
}

.ops-series-2 {
  background: var(--accent-line);
  fill: var(--accent-line);
}

/* On dark, the soft blue is too close to the page: the light accent text colour stands out. */
@media (prefers-color-scheme: dark) {
  .ops-series-2 {
    background: var(--accent-ink);
    fill: var(--accent-ink);
  }
}

.ops-series-3 {
  background: var(--ink-3);
  fill: var(--ink-3);
}

.ops-series-4 {
  background: repeating-linear-gradient(45deg, var(--ink-3) 0 2px, var(--bg) 2px 5px);
}

.ops-hatch__ground {
  fill: var(--bg);
}

.ops-hatch__ink {
  fill: var(--ink-3);
}

/* The small square that keys a provider to its colour. */
.ops-key {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.ops-chart {
  display: grid;
  gap: 8px;
}

.ops-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 18px;
}

.ops-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ops-chart__readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  line-height: 20px;
}

.ops-chart__value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ops-chart__when {
  color: var(--ink-3);
}

.ops-chart__parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
}

.ops-chart__part {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.ops-chart__plot {
  border-radius: var(--r-control);
  touch-action: pan-y;
}

.ops-chart__svg {
  display: block;
  overflow: visible;
}

.ops-chart__grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.ops-chart__base {
  stroke: var(--line);
  stroke-width: 1;
}

.ops-chart__tick {
  fill: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ops-chart__peak {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ops-chart__band {
  fill: var(--hover);
}

.ops-chart__hit {
  fill: transparent;
}

/* Where the budget ran out: the budget warning colour, the only place it shows in the chart. */
.ops-chart__over {
  stroke: var(--warn);
  stroke-width: 1;
}

.ops-chart__overtext {
  fill: var(--warn);
  font-size: 12px;
  font-weight: 600;
}

.ops-chart__foot {
  display: flex;
}

/* A quiet button that starts where the text above it starts. */
.ops-chart__foot .btn--quiet,
.ops-tracked__actions > .btn--quiet {
  margin-left: -6px;
}

/* The same numbers as a table, shown on request. */
.ops-chart__table {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
}

.ops-daytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.ops-daytable th,
.ops-daytable td {
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.ops-daytable thead th {
  border-top: 0;
  background: var(--panel);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}

.ops-daytable tfoot th,
.ops-daytable tfoot td {
  font-weight: 600;
}

.ops-daytable .ops-num {
  text-align: right;
}

/* ---------- Sheets ---------- */

.ops-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ops-facts {
  margin-top: 12px;
}

.ops-facts dd .inline {
  gap: 6px 10px;
}

/* Two or three numbers side by side: Expected and Actual, Amount and Next renewal. */
.ops-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.ops-pair--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ops-pair dt {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 16px;
}

.ops-pair dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.ops-pair dd.fig {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ops-fieldset {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ops-fieldset__legend {
  margin-bottom: 4px;
  padding: 0;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

/* The costs of an avenue, in its sheet. */
.ops-avcosts {
  margin-top: 12px;
}

.ops-avcosts__head {
  margin: 0 0 4px;
  font-weight: 500;
}

/* The kind switch in the expense form takes the full width. */
.ops-kind .seg {
  display: flex;
}

.ops-kind .seg__btn {
  flex: 1 1 0;
  padding: 0 8px;
}

/* The customer record on Sales: AI cost, price and margin side by side. */
.ops-aicost {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.ops-aicost dt {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 16px;
}

.ops-aicost dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Upload CSV ---------- */

.ops-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0;
}

.ops-steps:focus {
  outline: none;
}

.ops-steps__n {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 16px;
}

.ops-steps__title {
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
}

.ops-drop {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--control);
  border-radius: var(--r-box);
  background: var(--panel);
}

.ops-drop--over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ops-drop__input {
  padding: 6px 8px;
}

.ops-drop__input::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.ops-drop__hint {
  display: none;
}

@media (min-width: 900px) and (pointer: fine) {
  .ops-drop__hint {
    display: block;
  }
}

.ops-matches {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ops-match__name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.ops-errlist {
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 18px;
}

.ops-errlist li {
  overflow-wrap: anywhere;
}

.ops-import__done {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

/* ---------- The tab row and the project filter (SPEC-STEP8 4.1) ---------- */

/* Phones: the tabs as they are, the project filter on its own line under them. */
.ops-bar__project {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.ops-bar__project .ops-project {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

/* Laptops: the filter at the right end of the tab row, on the row's own line. */
@media (min-width: 900px) {
  .ops-bar--filter {
    display: flex;
    align-items: stretch;
    gap: 24px;
    margin: 0 calc(-1 * var(--gutter));
    padding: 0 var(--gutter);
    border-bottom: 1px solid var(--line);
  }

  .ops-bar--filter > .ptabs {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    border-bottom: 0;
  }

  .ops-bar--filter > .ops-bar__project {
    flex: none;
    align-self: center;
    padding: 0;
    border-bottom: 0;
  }

  .ops-bar__project .ops-project {
    flex: none;
    max-width: 280px;
  }
}

/* ---------- Projects (SPEC-STEP8 4.2) ---------- */

/* "None linked", "No project": quiet words inside a cell. */
.ops-quiet {
  color: var(--ink-3);
}

.ops-open {
  font-variant-numeric: tabular-nums;
}

/* The project sheet: "Open work" and "Open in Sales" under the status line, with the usual
   section gap (16px, as .sec) before the line under them. */
.ops-projlinks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 16px;
}

.ops-projadd {
  margin-top: 8px;
}

/* An avenue on a project: its name, and Remove for editors. */
.ops-linkline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ops-linkline__open {
  flex: 1 1 auto;
  min-width: 0;
  grid-template-areas: "title end";
}

.ops-linkline__btn {
  flex: none;
}

.ops-addav {
  margin-top: 12px;
}

/* OPS-B start */
/* Work items, SPEC-STEP8: "From:" on an apply item and "Also applies to the avenue". */

.ops-from {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 4px;
}

.ops-from__link {
  min-height: 24px;
  text-align: left;
  font: inherit;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.ops-applies {
  display: grid;
  gap: 4px;
}

/* The hint lines up with the checkbox's label (18px box + 10px gap). */
.ops-applies > .form__note,
.ops-applies > .form__error {
  margin-left: 28px;
}
/* "Also applies to the avenue" is a long label: it wraps rather than squeezing the values. */
.ops-facts--work {
  grid-template-columns: fit-content(40%) minmax(0, 1fr);
}
/* OPS-B end */
