/* 540 frame, one grid of 4 px black rules. The window's own border is the outer rule; the bar is
   48 px under it, its titles in cells divided by the same rule; a menu hangs from its title with
   its borders lying on the rules already there (the bar's bottom rule, the title's divider and,
   for the last menus, the window's edge).
   Cells (x of the divider to the left of each title): File 0, Edit 60, Invoices 125, Ledger 230,
   Reports 325, Window 430; the window ends at 540.
   Down the page everything keeps one pitch of 24 from y 56: a ledger row is 24, a menu row 48, a
   quarter 72. A menu's separators and its lower border are drawn inside its rows, and a submenu
   starts on its trigger's top edge, so every menu edge lies on a ledger rule and no ledger row is
   ever cut along its length. */
.wb {
  --ink: #000;
  --paper: #fff;
  --loud: #1a1aff;
  --off: #8f8f8f;
  --row: 48px;
  position: relative;
  box-sizing: border-box;
  width: 540px;
  height: 540px;
  overflow: hidden;
  border: 4px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: "Tinos", serif;
  font-variant-numeric: lining-nums tabular-nums;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.wb *,
.wb-menu,
.wb-menu * {
  box-sizing: border-box;
}

/* ---------- the bar ---------- */

.wb-bar {
  display: grid;
  grid-template-columns: 56px 61px 101px 91px 101px 102px;
  column-gap: 4px;
  height: 52px;
  border-bottom: 4px solid var(--ink);
  background: var(--ink);
}

.wb-title {
  display: grid;
  place-items: center;
  height: 48px;
  margin: 0;
  padding: 0 0 1px;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 700 24px/48px "Tinos", serif;
  letter-spacing: 0;
  outline: none;
  cursor: default;
}

.wb-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.wb-title:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.wb-title[data-open] {
  background: var(--loud);
  color: var(--paper);
  text-decoration: none;
}

/* ---------- a menu ---------- */

.wb-menu {
  --ink: #000;
  --paper: #fff;
  --loud: #1a1aff;
  --off: #8f8f8f;
  --row: 48px;
  width: 310px;
  margin: 0;
  padding: 0;
  border: solid var(--ink);
  border-width: 4px 4px 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Tinos", serif;
  font-variant-numeric: lining-nums tabular-nums;
  outline: none;
  overflow: visible;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.wb-menu[data-menu="vat"] {
  width: 234px;
}

.wb-menu[data-menu="export"] {
  width: 234px;
}

.wb-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: var(--row);
  padding: 0 10px 1px 30px;
  color: var(--ink);
  font-size: 23px;
  line-height: 28px;
  white-space: nowrap;
  outline: none;
  cursor: default;
}

.wb-item[data-highlighted] {
  background: var(--loud);
  color: var(--paper);
}

/* the way in to an open submenu stays marked while the highlight is inside it */
.wb-item[data-open] {
  background: var(--ink);
  color: var(--paper);
}

.wb-item[data-disabled] {
  color: var(--off);
}

/* a dead item can still be reached; it is marked without the loud colour */
.wb-item[data-disabled][data-highlighted] {
  background: var(--off);
  color: var(--paper);
}

/* the lower border is the last 4 px of the last row */
.wb-menu > .wb-item:last-child,
.wb-menu > :last-child > .wb-item:last-child {
  border-bottom: 4px solid var(--ink);
}

/* a separator is the first 4 px of the row under it */
.wb-rule {
  position: relative;
  z-index: 1;
  height: 4px;
  margin-bottom: -4px;
  background: var(--ink);
}

.wb-rule + .wb-item,
.wb-rule + * > .wb-item:first-child {
  padding-top: 4px;
}

/* a submenu's upper border is the first 4 px of its first row */
.wb-sub {
  border-top-width: 0;
}

.wb-sub > .wb-item:first-child {
  border-top: 4px solid var(--ink);
}

/* shortcut: drawn modifiers, a mono capital */
.wb-keys {
  display: flex;
  align-items: center;
  gap: 1px;
  font: 700 19px/28px "Courier Prime", monospace;
}

.wb-keys svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linejoin: miter;
  stroke-linecap: square;
}

.wb-keys b {
  width: 13px;
  margin-left: 2px;
  font-weight: 700;
  text-align: center;
  translate: 0 1.5px;
}

/* the gutter marks sit in the 32 px left of the label */
.wb-box,
.wb-dot,
.wb-arrow {
  position: absolute;
  top: 50%;
}

.wb-box {
  left: 7px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid currentColor;
}

.wb-cross {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(45deg, transparent calc(50% - 1.2px), currentColor calc(50% - 1.2px) calc(50% + 1.2px), transparent calc(50% + 1.2px)),
    linear-gradient(-45deg, transparent calc(50% - 1.2px), currentColor calc(50% - 1.2px) calc(50% + 1.2px), transparent calc(50% + 1.2px));
}

.wb-dot {
  left: 10px;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background: currentColor;
}

.wb-arrow {
  left: 8px;
  width: 12px;
  height: 14px;
  margin-top: -7px;
  fill: currentColor;
}

.wb-item[data-side="right"] .wb-arrow {
  left: auto;
  right: 10px;
  rotate: 180deg;
}

/* a quarter: the period over where its return stands */
.wb-quarter {
  grid-template-columns: 1fr;
  grid-template-rows: 28px 19px;
  align-content: center;
  height: 72px;
  padding: 0 10px 1px 12px;
}

.wb-quarter + .wb-quarter {
  border-top: 1px solid var(--ink);
}

.wb-status {
  font: 400 15px/18px "Courier Prime", monospace;
}

/* ---------- the ledger under it ---------- */

.wb-ledger {
  width: 532px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 16px;
  line-height: 20px;
}

.wb-ledger th,
.wb-ledger td {
  height: 24px;
  padding: 0 8px 1px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  overflow: hidden;
  text-align: left;
  white-space: nowrap;
}

.wb-ledger th {
  border-bottom-width: 2px;
  font-weight: 700;
}

.wb-ledger :is(th, td):last-child {
  border-right: 0;
}

.wb-ledger th:nth-child(1) {
  width: 66px;
}

.wb-ledger th:nth-child(2) {
  width: 80px;
}

.wb-ledger th.wb-num {
  width: 66px;
}

.wb-ledger th.wb-num:last-child {
  width: 76px;
}

.wb-ledger .wb-num {
  text-align: right;
}

.wb-ref {
  font: 400 14px/20px "Courier Prime", monospace;
}
