/* stylelint-disable no-descending-specificity */

.flex-table p,
.flex-table li,
.flex-table ul,
.flex-table ol {
  padding: 0;
  margin: 0;
}

.flex-table p {
  display: flex;
}

.flex-table p > span {
  flex-shrink: 0;
  padding: 2px 4px;
}

.flex-table .num {
  font-family: var(--font-family-monospaced);
  text-align: right;
}

.flex-table .head p > span {
  padding: 3px 4px;
  color: var(--table-header-text);
  background-color: var(--table-header-background);
}

.flex-table .head .num {
  font-family: var(--font-family);
}

.journal {
  margin-top: 0.25rem;
}

.journal p,
.journal dl {
  border-bottom: thin solid var(--table-border);
}

.journal .payee {
  cursor: pointer;
}

.journal .postings {
  font-size: 0.9em;
  background-color: var(--journal-postings);
  opacity: 0.8;
}

.journal .postings .num {
  overflow: auto;
  line-height: 16px;
}

.journal > li,
.journal.show-custom .custom.budget,
.journal.show-document .document.discovered,
.journal.show-document .document.linked,
.journal .metadata,
.journal .postings {
  display: none;
}

.journal .head,
.journal.show-balance .balance,
.journal.show-close .close,
.journal.show-custom .custom,
.journal.show-document .document,
.journal.show-note .note,
.journal.show-open .open,
.journal.show-pad .pad,
.journal.show-query .query,
/* Show metadata and postings if it was toggled for the whole journal. */
.journal.show-metadata .metadata,
.journal.show-postings .postings,
/* Show metadata and postings where it was explicitly toggled with the indicators. */
.journal > li.show-full-entry .postings,
.journal > li.show-full-entry .metadata {
  display: block;
}

.journal.show-transaction.show-cleared .transaction.cleared,
.journal.show-transaction.show-pending .transaction.pending,
.journal.show-transaction.show-other .transaction.other,
.journal.show-document.show-discovered .document.discovered,
.journal.show-document.show-linked .document.linked,
.journal.show-custom.show-budget .custom.budget {
  display: block;
}

.journal .transaction:hover {
  background: var(--journal-hover-highlight);
}

/* Metadata */
.journal .metadata {
  padding: 2px 0;
  margin: 0;
  font-size: 0.9em;
}

.journal .metadata dt {
  float: left;
  width: auto;
  min-width: 4rem;
  margin-right: 6px;
  margin-left: 9rem;
  color: var(--journal-metadata);
  cursor: pointer;
}

.journal .metadata dd {
  margin-left: 15rem;
  cursor: pointer;
}

/* There's three number columns (units, cost, price).
 * They should add about to about half of the width */
.journal p > .num {
  width: min(calc(15%), 20rem);
  border-left: 1px solid var(--table-border);
}

.journal .datecell,
.journal .flag {
  text-align: center;
  background-color: var(--entry-background);
}

.journal .datecell {
  width: 6rem;
  white-space: nowrap;
}

.journal .flag {
  width: 3rem;
}

.journal .change {
  font-weight: 500;
}

.journal .description {
  flex: 1;
  padding-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal .show-postings .description {
  white-space: normal;
}

.journal .description .separator::before {
  padding: 2px;
  margin: 0 6px;
  font-weight: bold;
  color: var(--text-color-lighter);
  content: "•";
}

.journal .description .num {
  margin: 0 5px;
}

.journal .tag,
.journal .link {
  margin-left: 8px;
  font-size: 0.9em;
  cursor: pointer;
}

.journal .tag {
  color: var(--journal-tag);
}

.journal .link {
  color: var(--journal-link);
}

.journal .bal {
  background-color: var(--entry-background);
}

.journal a:hover {
  filter: brightness(80%);
}

.journal .filename,
.journal .url {
  font-family: var(--font-family-monospaced);
  font-size: 0.9em;
}

.journal .document .filename {
  margin-left: 1em;
}

.journal .indicators {
  display: flex;
  flex-shrink: 3;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}

.journal .indicators span {
  min-width: 6px;
  height: 6px;
  padding: 0;
  margin-right: 4px;
  background-color: var(--journal-posting-indicator);
  border-radius: 3px;
}

.journal .indicators .pending,
.journal .indicators .other {
  background-color: var(--entry-background);
}

.journal .indicators .metadata-indicator {
  height: 16px;
  padding: 0 6px;
  font-size: 10px;
  line-height: 16px;
  color: var(--journal-metadata-indicator);
  text-transform: lowercase;
  border-radius: 20px;
}

@media (width <= 767px) {
  .journal p {
    flex-wrap: wrap;
  }

  /* show a colored top border for all entries */
  .journal > li > p {
    border-top: thin solid var(--entry-background);
  }

  .journal .head .flag {
    flex-grow: 1;
    text-align: left;
  }

  .journal .description {
    flex: inherit;
    order: 1; /* push to second row */
    width: 100%;
    padding-left: 0;
  }

  .journal .indicators {
    flex-grow: 1;
  }

  .journal .balance .num {
    width: 35%;
  }

  .journal .balance .change.num {
    display: none;
  }

  .journal .postings .datecell,
  .journal .postings .flag {
    display: none;
  }

  .journal .postings .description {
    flex-grow: 1;
    order: inherit;
    width: inherit;
  }

  .journal .metadata dt,
  .journal .metadata dd {
    margin-left: initial;
  }
}
