/* The company ledger on the counter: a clothbound book with leather corners, a block of page edges, the open page
   (ledger paper, red and blue rules), leather thumb tabs, and the duty tag. */

.ledger-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: clamp(70px, 9vh, 96px) clamp(150px, 12vw, 210px) clamp(18px, 3vh, 34px) clamp(16px, 4vw, 60px);
  perspective: 2200px;
}
.ledger-stage.arriving .ledger { animation: ledger-arrive 1s cubic-bezier(.2, .75, .25, 1) both; }
@keyframes ledger-arrive {
  from { transform: translate3d(0, 55vh, 0) rotateX(32deg) rotate(-4deg); opacity: 0; }
  60% { opacity: 1; }
  80% { transform: translate3d(0, -4px, 0) rotate(0.2deg); }
}

.ledger {
  position: relative;
  width: min(1180px, 100%);
  height: 100%;
  transform: rotate(-0.4deg);
  transform-style: preserve-3d;
}

/* The binding: dark green buckram with oxblood leather corners and a gilt rule, larger than the pages. */
.ledger-cover {
  position: absolute;
  inset: -16px -14px -18px -34px;
  border-radius: 6px 10px 10px 6px;
  background:
    linear-gradient(135deg, #3c1612 0 46px, transparent 46px) top left / 100% 100% no-repeat,
    linear-gradient(225deg, #3c1612 0 46px, transparent 46px) top right / 100% 100% no-repeat,
    linear-gradient(45deg, #3c1612 0 46px, transparent 46px) bottom left / 100% 100% no-repeat,
    linear-gradient(315deg, #3c1612 0 46px, transparent 46px) bottom right / 100% 100% no-repeat,
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 5px),
    var(--img-leather, none),
    linear-gradient(160deg, #1f3328, #12201a 70%);
  background-blend-mode: normal, normal, normal, normal, normal, soft-light, normal;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7), 0 6px 14px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(0, 0, 0, 0.5);
}
/* The spine's shadow along the left edge of the page. */
.ledger-cover::after {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 14px;
  width: 26px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15) 60%, transparent);
}

/* Gilt lettering across the head of the binding. */
.ledger-band {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: -15px;
  height: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  pointer-events: none;
  font-family: var(--font-deco);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: transparent;
  background: linear-gradient(180deg, #fff1bf, #d9b25c 45%, #8e6620 60%, #e9cc81);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.9));
}
.ledger-kind { font-family: var(--font-stencil); letter-spacing: 0.4em; }

/* The block of pages under the open one: fine edges showing at the right and bottom. */
.ledger-block {
  position: absolute;
  inset: 3px -6px -7px 0;
  border-radius: 2px 5px 5px 2px;
  background:
    repeating-linear-gradient(90deg, #d8cfb4 0 1px, #b9ae90 1px 2px) right / 6px 100% no-repeat,
    repeating-linear-gradient(180deg, #d8cfb4 0 1px, #b9ae90 1px 2px) bottom / 100% 7px no-repeat,
    #cfc5a8;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}

.ledger-pages { position: absolute; inset: 0; transform-style: preserve-3d; }

.lpage {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.lpage.turning { z-index: 3; will-change: transform; }
.lface { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; }
.lface.back {
  transform: rotateY(180deg);
  background-color: #e3dbc1;
  background-image: var(--img-paper, none);
  background-size: 700px;
  background-blend-mode: multiply;
  box-shadow: inset -30px 0 40px rgba(0, 0, 0, 0.18);
}
.lshade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.12) 60%, transparent);
}

/* Ledger paper: warm cream, a band at the head, a red double rule at the margin and a blue one beside it. */
.lpage .sheet {
  --paper: #e2dbc2;
  min-height: 0;
  overflow: auto;
  padding: clamp(18px, 3vh, 34px) clamp(18px, 3vw, 46px) 40px clamp(48px, 5.6vw, 84px);
  border-radius: 1px 3px 3px 1px;
  background-image:
    linear-gradient(90deg, transparent calc(clamp(48px, 5.6vw, 84px) - 22px), rgba(168, 42, 32, 0.5) calc(clamp(48px, 5.6vw, 84px) - 22px) calc(clamp(48px, 5.6vw, 84px) - 21px), transparent calc(clamp(48px, 5.6vw, 84px) - 21px) calc(clamp(48px, 5.6vw, 84px) - 18px), rgba(168, 42, 32, 0.5) calc(clamp(48px, 5.6vw, 84px) - 18px) calc(clamp(48px, 5.6vw, 84px) - 17px), transparent calc(clamp(48px, 5.6vw, 84px) - 17px) calc(clamp(48px, 5.6vw, 84px) - 12px), rgba(50, 80, 140, 0.35) calc(clamp(48px, 5.6vw, 84px) - 12px) calc(clamp(48px, 5.6vw, 84px) - 11px), transparent calc(clamp(48px, 5.6vw, 84px) - 11px)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 34px),
    linear-gradient(170deg, rgba(255, 252, 242, 0.16), transparent 35%, transparent 70%, rgba(90, 65, 30, 0.08)),
    var(--img-paper, none);
  background-size: auto, auto, auto, 700px 700px;
  background-blend-mode: normal, normal, normal, multiply;
  box-shadow: 0 0 0 0.5px rgba(70, 55, 35, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.lpage .sheet::-webkit-scrollbar { width: 9px; }
.lpage .sheet::-webkit-scrollbar-thumb { background: rgba(60, 45, 25, 0.45); border-radius: 9px; }
.sheet:focus-visible { outline: none; }

/* Leather thumb tabs on the fore-edge. */
.ledger-tabs {
  position: absolute;
  z-index: 4;
  top: 40px;
  left: calc(100% + 6px);
  display: grid;
  gap: 6px;
}
.ltab {
  position: relative;
  min-width: 150px;
  padding: 10px 14px 10px 16px;
  white-space: nowrap;
  border: 0;
  border-radius: 0 7px 7px 0;
  text-align: left;
  cursor: pointer;
  color: #f0dfb4;
  font: 0.74rem var(--font-type);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background:
    linear-gradient(180deg, rgba(255, 220, 170, 0.12), transparent 40%, rgba(0, 0, 0, 0.25)),
    var(--img-leather, none),
    #4a1c16;
  background-size: auto, 300px, auto;
  background-blend-mode: normal, multiply, normal;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.45), inset 3px 0 6px rgba(0, 0, 0, 0.45);
  transform: translateX(-10px);
  transition: transform 0.25s cubic-bezier(.2, .8, .3, 1), filter 0.2s;
  filter: brightness(0.82);
}
.ltab span { position: relative; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8); }
.ltab::after { /* a gilt line stamped on the leather */
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 5px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(236, 209, 137, 0.6), transparent);
}
.ltab:hover { transform: translateX(-4px); filter: brightness(0.95); }
.ltab.active { transform: translateX(0); filter: none; color: #fff2cc; }
.ltab:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* ---------- Content on the page (shared by the rooms) ---------- */

.manila {
  background-color: var(--manila);
  background-image:
    linear-gradient(180deg, rgba(255, 248, 225, 0.13), transparent 30%, transparent 72%, rgba(70, 45, 10, 0.10)),
    var(--img-manila, none);
  background-size: auto, 640px 640px;
  background-blend-mode: normal, multiply;
}
.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 20px;
  border-bottom: 2px solid rgba(30, 25, 20, 0.6);
  padding-bottom: 10px;
  margin-bottom: 22px;
}
.sheet-head h1 {
  margin: 0;
  font-family: var(--font-stencil);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.6vw, 2.2rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2a2117;
}
.sheet-head .sub { font-family: var(--font-type); font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); }
.sheet-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.placeholder-memo { max-width: 620px; margin: 40px auto; text-align: center; }
.placeholder-memo .hand { font-size: 1.8rem; }

/* A brass tally as a small badge (crew files, time cards). */
.rs-tally {
  display: inline-grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  flex: none;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 0.4em;
  font: 700 0.95rem/1 var(--font-stencil);
  color: rgba(52, 34, 8, 0.85);
  background:
    radial-gradient(circle at 50% 13%, #1a130a 0 8%, transparent 9%),
    radial-gradient(circle at 36% 30%, #f6e3a4, #c9a24f 42%, #8a6524 78%, #5c4116);
  box-shadow: inset 0 0 0 1.5px rgba(80, 55, 18, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 0 rgba(255, 236, 170, 0.55);
}
.rs-tally span { padding-top: 0.25em; }
.rs-tally.small { font-size: 0.75rem; margin-left: 0; }

/* ---------- Duty tag (who is signed in, and whether they're on shift) ---------- */

.duty-tag {
  position: fixed;
  z-index: 7;
  top: clamp(10px, 2vh, 22px);
  right: clamp(12px, 2vw, 30px);
  display: grid;
  gap: 2px;
  padding: 8px 14px 9px 26px;
  max-width: 260px;
  background-color: #e3d9bf;
  background-image: var(--img-paper, none);
  background-size: 500px;
  background-blend-mode: multiply;
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55));
  transform: rotate(2deg);
  transform-origin: 0 50%;
  cursor: pointer;
  border: 0;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.duty-tag::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #2a2017;
  box-shadow: 0 0 0 2px #b48f3e;
}
.duty-tag .rank { font-family: var(--font-type); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.duty-tag .who { font-family: var(--font-hand); font-size: 1.35rem; line-height: 1; color: var(--graphite); }
.duty-tag .shift { font-family: var(--font-type); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: #4a2f7a; }
.duty-tag .shift.off { color: var(--ink-soft); opacity: 0.8; }
.duty-menu {
  position: fixed;
  z-index: 8;
  top: calc(clamp(10px, 2vh, 22px) + 74px);
  right: clamp(12px, 2vw, 30px);
  display: grid;
  min-width: 230px;
  padding: 6px;
  gap: 2px;
}
.duty-menu button { text-align: left; border: 0; background: none; padding: 8px 10px; font-family: var(--font-type); font-size: 0.85rem; cursor: pointer; color: var(--ink); }
.duty-menu button:hover { background: rgba(0, 0, 0, 0.07); }

/* ---------- Narrow windows: tabs along the top edge of the page ---------- */

@media (max-width: 900px) {
  .ledger-stage { padding: 112px 14px 76px 22px; }
  .ledger-tabs { left: 0; right: 0; top: auto; bottom: calc(100% + 18px); display: flex; overflow-x: auto; scrollbar-width: none; gap: 4px; padding: 0 2px; }
  .ltab { min-width: 0; flex: 0 0 auto; border-radius: 7px 7px 0 0; transform: translateY(8px); padding: 8px 12px; }
  .ltab:hover { transform: translateY(4px); }
  .ltab.active { transform: none; }
  .ledger-band { display: none; }
  .duty-tag { max-width: 190px; }
}
@media (max-width: 560px) {
  .duty-tag { top: 8px; right: 6px; max-width: 150px; padding: 5px 10px 6px 21px; }
  .duty-tag::before { left: 11px; }
  .duty-tag .rank { font-size: 0.5rem; letter-spacing: 0.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .duty-tag .who { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ledger-cover { inset: -8px -6px -10px -14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ledger-stage.arriving .ledger { animation: none; }
}
