/* Juling Books — "Carbon Copy Set": carbon-navy ink on form stock; the copy a month reached is its status. */

@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-tight-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-tight-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* ink + stock */
  --ink: #16213e;
  --ink-2: #4a5372;
  --ink-3: #5c6480;
  --rule: #d5d9e3;
  --rule-strong: var(--ink);
  --ground: #f6f7fa;
  --stock: #ffffff;
  --stock-2: #fafbfc;
  /* shell */
  --rail: #1a1a2e;
  --rail-ink: #c9cee0;
  --rail-ink-2: #a3aac4;
  --rail-rule: #2f2f48;
  /* actions + live */
  --primary: #0f3460;
  --primary-hover: #0a2747;
  --teal: #115264;
  --teal-hover: #0c3f4d;
  --live: #533483;
  --live-wash: #f3eff9;
  /* copy sheets = billing status */
  --copy-white: #ffffff;
  --copy-yellow: #f3e6a3;
  --copy-pink: #f1c6d0;
  --copy-green: #cfe3cf;
  /* status marks: one colour per billing state, on the row's left edge */
  --st-work: #c3c8d6;
  --st-active: #533483;
  --st-unbilled: #a3243b;
  --st-draft: #8a91a8;
  --st-sevdesk: #c9a227;
  --st-open: #c2416b;
  --st-paid: #3f8f4f;
  --st-cancelled: #d5d9e3;
  /* states */
  --alert: #a3243b;
  --alert-wash: #fdf4f6;
  --ok: #2f6b3a;
  --ok-wash: #eef6ee;
  --focus: #0f3460;
  /* partner marks */
  --mark-0: #4f6d8a;
  --mark-1: #7a6a4f;
  --mark-2: #5d7a62;
  --mark-3: #7b5873;

  --font: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 4px;
  --rail-w: 216px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: #b9bfcf transparent;
}
body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
  color: var(--ink);
  background: var(--ground);
  min-height: 100vh;
}
::selection {
  background: var(--copy-yellow);
  color: var(--ink);
}
h1,
h2,
h3,
p {
  margin: 0;
}
a {
  color: var(--teal);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover {
  color: var(--teal-hover);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
  caret-color: var(--live);
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.muted {
  color: var(--ink-3);
}
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  white-space: nowrap;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  padding: 8px 12px 24px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand span {
  color: var(--rail-ink-2);
  font-weight: 500;
}
.rail nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail nav a {
  color: var(--rail-ink);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--r);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.rail nav a:hover {
  background: #26263f;
  color: #fff;
}
.rail nav a[aria-current="page"] {
  background: #fff;
  color: var(--rail);
}
.rail nav .count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: #f1c6d0;
}
.rail nav a[aria-current="page"] .count {
  color: var(--alert);
}
.rail-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--rail-rule);
  font-size: 13px;
  color: var(--rail-ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rail-foot form {
  margin-left: auto;
}
.rail-foot button {
  background: none;
  border: 0;
  color: var(--rail-ink-2);
  cursor: pointer;
  padding: 4px;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rail-foot button:hover {
  color: #fff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--stock);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.topbar h1 span {
  color: var(--ink-3);
  font-weight: 400;
}
.topbar .grow {
  flex: 1;
}
.subbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--stock);
  min-height: 44px;
}
.content {
  padding: 24px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

/* ------------------------------------------------------------ live timer chip */

.timer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--live);
  border-radius: 17px;
  color: var(--live);
  font-weight: 500;
  max-width: 460px;
}
.timer b {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.timer .what {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.timer .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  flex: none;
  animation: pulse 2s var(--ease) infinite;
}
.timer button {
  border: 0;
  background: var(--live);
  color: #fff;
  border-radius: 13px;
  height: 26px;
  padding: 0 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.timer button:hover {
  background: #432a6b;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--rule);
  background: var(--stock);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-hover);
}
.btn.secondary {
  color: var(--teal);
  border-color: var(--teal);
}
.btn.secondary:hover {
  background: #eef5f6;
}
.btn.danger {
  color: var(--alert);
  border-color: #e3b4bf;
}
.btn.danger:hover {
  background: var(--alert-wash);
  border-color: var(--alert);
}
.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--ground);
  color: var(--ink);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.htmx-request .btn[type="submit"],
.btn.htmx-request {
  opacity: 0.6;
  cursor: progress;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.label,
.field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.input,
.field input,
.field select,
.field textarea,
select.input {
  height: 36px;
  border: 1px solid var(--rule);
  border-bottom-color: #aab1c4;
  border-radius: var(--r);
  background: var(--stock);
  padding: 0 10px;
  width: 100%;
  min-width: 0;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.field textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}
.input:hover,
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #aab1c4;
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.16);
}
.field input::placeholder,
.input::placeholder {
  color: var(--ink-3);
}
.field input[aria-invalid="true"] {
  border-color: var(--alert);
}
.hint {
  font-size: 12px;
  color: var(--ink-3);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.tabs {
  display: flex;
  gap: 24px;
  align-self: stretch;
}
.tabs a {
  display: flex;
  align-items: center;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover {
  color: var(--ink);
}
.tabs a[aria-current="true"] {
  color: var(--ink);
  box-shadow: inset 0 -2px var(--ink);
}
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--stock);
}
.stepper a,
.stepper span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  padding: 0 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.stepper span {
  border-inline: 1px solid var(--rule);
  padding: 0 12px;
  min-width: 128px;
}
.stepper a:hover {
  background: var(--ground);
}

/* ------------------------------------------------------------ flash */

#flash:empty {
  display: none;
}
.flash {
  padding: 10px 14px;
  border: 1px solid var(--ok);
  background: var(--ok-wash);
  color: var(--ok);
  border-radius: var(--r);
  font-weight: 500;
}
.flash-error {
  border-color: var(--alert);
  background: var(--alert-wash);
  color: var(--alert);
}
.field-error {
  color: var(--alert);
  font-size: 13px;
  font-weight: 500;
}

/* ------------------------------------------------------------ forms (the printed sheet) */

.sheet {
  background: var(--stock);
  border: 1px solid var(--rule-strong);
}
.sheet-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule-strong);
}
.sheet-head h2 {
  font-size: 16px;
  font-weight: 600;
}
.sheet-head .meta {
  color: var(--ink-2);
}
.sheet-head .totals {
  margin-left: auto;
  display: flex;
  gap: 24px;
}
.sheet-body {
  padding: 16px;
}
.figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.figure b {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.figure b.alert {
  color: var(--alert);
}
.figure.left {
  align-items: flex-start;
}

/* ------------------------------------------------------------ copy-sheet stack (signature) */

.pad {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  height: 30px;
  width: 30px;
  flex: none;
}
.pad i {
  position: absolute;
  width: 10px;
  border: 1px solid var(--ink);
  background: var(--copy-white);
  transition: transform 200ms var(--ease);
}
.pad i:nth-child(1) {
  left: 0;
  top: 6px;
  bottom: 0;
}
.pad i:nth-child(2) {
  left: 5px;
  top: 4px;
  bottom: 2px;
}
.pad i:nth-child(3) {
  left: 10px;
  top: 2px;
  bottom: 4px;
}
.pad i:nth-child(4) {
  left: 15px;
  top: 0;
  bottom: 6px;
}
.pad i.yellow {
  background: var(--copy-yellow);
}
.pad i.pink {
  background: var(--copy-pink);
}
.pad i.green {
  background: var(--copy-green);
}
.pad.draft i:nth-child(1) {
  border-style: dashed;
}
.pad.cancelled i {
  background: var(--ground);
  border-color: var(--ink-3);
}
tr:hover .pad i:last-child,
.month:hover .pad i:last-child {
  transform: translateY(-2px);
}

.status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
}
.status small {
  display: block;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-3);
  font-size: 12px;
}
.status.alert,
.status.alert small {
  color: var(--alert);
}
.status.live {
  color: var(--live);
}

.legend {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 13px;
  border: 1px solid var(--ink);
  margin-right: 5px;
  vertical-align: -2px;
}

/* ------------------------------------------------------------ partner marks */

.mark {
  width: 18px;
  height: 18px;
  border-radius: 2px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex: none;
  background: var(--mark-0);
}
.mark.m1 {
  background: var(--mark-1);
}
.mark.m2 {
  background: var(--mark-2);
}
.mark.m3 {
  background: var(--mark-3);
}
.who {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--ink-2);
}

/* ------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
}
table.ledger {
  width: 100%;
  border-collapse: collapse;
}
.ledger th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.ledger th.num {
  text-align: right;
}
.ledger td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.ledger tbody tr:last-child td {
  border-bottom: 0;
}
.ledger tbody tr {
  transition: background-color 150ms var(--ease);
}
.ledger tbody tr:hover {
  background: var(--stock-2);
}
.ledger td:first-child,
.ledger th:first-child {
  padding-left: 16px;
}
.ledger td:last-child,
.ledger th:last-child {
  padding-right: 16px;
}
.ledger .month-name {
  font-weight: 600;
  white-space: nowrap;
}
.ledger .amount {
  font-weight: 600;
}
.ledger .actions {
  text-align: right;
  white-space: nowrap;
}
.ledger .actions .btn + .btn {
  margin-left: 4px;
}
.ledger tr.current .month-name {
  color: var(--live);
}
.ledger tr.due {
  background: var(--alert-wash);
}
.ledger tr.due:hover {
  background: #fbecf0;
}
.ledger tr.day-head td {
  background: var(--stock-2);
  padding-top: 8px;
  padding-bottom: 8px;
  font-weight: 600;
  border-bottom-color: var(--rule);
}
.ledger tr.day-head.today td {
  color: var(--live);
}
.ledger tr.saved {
  animation: saved 1.2s var(--ease);
}
@keyframes saved {
  from {
    background: var(--live-wash);
  }
}
.ledger tfoot td {
  border-top: 1px solid var(--rule-strong);
  font-weight: 600;
  padding: 10px 12px;
}
.ledger .contract {
  white-space: nowrap;
}
.ledger tr.editing select[name="contract_id"] {
  min-width: 210px;
}
.ledger .time {
  white-space: nowrap;
  color: var(--ink-2);
}
.ledger .desc {
  min-width: 220px;
}
.ledger .desc .muted {
  font-style: italic;
}
.ledger tr.editing td {
  background: #fffdf3;
  vertical-align: top;
}
.ledger tr.editing .input {
  height: 34px;
}
.ledger tr.deleted td {
  color: var(--ink-3);
  background: var(--ground);
}
.row-error td {
  padding-top: 0 !important;
}

.issue {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}
.issue code {
  font: 600 12px/1.6 var(--font);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 5px;
  color: var(--ink);
  background: var(--stock-2);
  white-space: nowrap;
}
.issue span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.issue:hover code {
  border-color: var(--ink-3);
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 5px;
  line-height: 1.5;
  white-space: nowrap;
}
.tag.live {
  color: var(--live);
}
.tag.mcp {
  color: var(--teal);
}
.tag.lock {
  color: var(--ink-3);
}

/* ------------------------------------------------------------ today */

.entry-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 140px 96px 96px 96px;
  gap: 12px;
  align-items: end;
}
.entry-form .wide {
  grid-column: 1 / 4;
}
.entry-form .issue-field {
  grid-column: 4 / 6;
}
.entry-form .submit {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.entry-form .submit .hint {
  margin-left: auto;
}
.or {
  font-size: 12px;
  color: var(--ink-3);
  align-self: center;
  padding-top: 18px;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--rule);
}
.week a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 12px;
  text-decoration: none;
  color: var(--ink-2);
  border-right: 1px solid var(--rule);
  font-size: 12px;
}
.week a:last-child {
  border-right: 0;
}
.week a:hover {
  background: var(--stock-2);
}
.week a b {
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.week a[aria-current="date"] {
  box-shadow: inset 0 -2px var(--ink);
  color: var(--ink);
}
.week a.today b {
  color: var(--live);
}
/* the day's ink against an 8h line */
.daybar {
  height: 4px;
  background: var(--ground);
  position: relative;
}
.daybar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ink);
  max-width: 100%;
}
.daybar.over i {
  background: var(--alert);
}

/* ------------------------------------------------------------ overview */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notice {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid var(--alert);
  background: var(--alert-wash);
}
.notice p {
  flex: 1;
  min-width: 220px;
}
.notice strong {
  color: var(--alert);
}
.budget {
  display: grid;
  grid-template-columns: repeat(3, auto) minmax(220px, 1fr);
  gap: 32px;
  align-items: end;
}
.budget-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.budget-bar .track {
  position: relative;
  height: 12px;
  border: 1px solid var(--ink);
  margin-right: 20%;
}
.budget-bar .fill {
  position: absolute;
  left: 0;
  top: -1px;
  bottom: -1px;
}
.budget-bar .fill {
  background: var(--ink);
}
/* the part past the 100 % tick spills over the frame in alert red */
.budget-bar .overrun {
  position: absolute;
  left: 100%;
  top: -1px;
  bottom: -1px;
  background: var(--alert);
}
.budget-bar .tick {
  position: absolute;
  right: -1px;
  top: -6px;
  bottom: -6px;
  width: 2px;
  background: var(--ink);
}
.budget-bar .scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  margin-right: 20%;
}
.people {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.people .who b {
  font-size: 15px;
}

/* ------------------------------------------------------------ invoices */

.lines .input {
  height: 34px;
}
.lines td {
  vertical-align: top;
}
.email {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.email textarea {
  min-height: 220px;
  font-size: 13px;
  line-height: 1.5;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
}
.kv dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 2px;
}
.kv dd {
  margin: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
}
.danger-zone {
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  margin-top: 8px;
}

/* ------------------------------------------------------------ history */

.diff {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
}
.diff del {
  color: var(--alert);
  text-decoration-thickness: 1px;
}
.diff ins {
  color: var(--ok);
  text-decoration: none;
  font-weight: 500;
}
.diff .k {
  color: var(--ink-3);
}
dialog.sheet {
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(22, 33, 62, 0.28);
}
dialog::backdrop {
  background: rgba(26, 26, 46, 0.45);
}
dialog .sheet-head button {
  margin-left: auto;
}

/* ------------------------------------------------------------ empty states */

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.empty strong {
  color: var(--ink);
  font-size: 15px;
}

/* ------------------------------------------------------------ login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--rail);
}
.login .sheet {
  width: min(400px, 100%);
}
.login .brand {
  padding: 0 0 4px;
  color: var(--ink);
  font-size: 20px;
}
.login .brand span {
  color: var(--ink-3);
}
.login .pad-art {
  display: flex;
  gap: 0;
}

/* ------------------------------------------------------------ settings */

.settings-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.toc {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc a {
  padding: 6px 10px;
  border-radius: var(--r);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
}
.toc a:hover {
  background: var(--stock);
  color: var(--ink);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.form-grid .span-2 {
  grid-column: span 2;
}
.token {
  font: 600 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--copy-yellow);
  border: 1px solid var(--ink);
  padding: 10px 12px;
  word-break: break-all;
  user-select: all;
}
details.sub {
  border-top: 1px solid var(--rule);
}
details.sub > summary {
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  list-style: none;
}
details.sub > summary::-webkit-details-marker {
  display: none;
}
details.sub > summary:hover {
  background: var(--stock-2);
}
details.sub[open] > summary {
  border-bottom: 1px solid var(--rule);
}
details.sub > div {
  padding: 16px;
}
.chev {
  transition: transform 200ms var(--ease);
}
details[open] > summary .chev {
  transform: rotate(90deg);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .cols {
    grid-template-columns: minmax(0, 1fr);
  }
  .budget {
    grid-template-columns: repeat(3, auto);
  }
  .budget-bar {
    grid-column: 1 / -1;
  }
}
@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    overflow-x: auto;
    gap: 4px;
  }
  .brand {
    padding: 6px 8px;
    font-size: 15px;
  }
  .rail nav {
    flex-direction: row;
  }
  .rail nav a {
    padding: 8px 10px;
    min-height: 44px;
  }
  .rail nav .count {
    margin-left: 4px;
  }
  .rail-foot {
    display: none;
  }
  .topbar {
    position: static;
    padding: 12px 16px;
  }
  .subbar,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }
  .entry-form {
    grid-template-columns: 1fr 1fr;
  }
  .entry-form > * {
    grid-column: auto;
  }
  .entry-form .wide,
  .entry-form .issue-field,
  .entry-form .contract-field {
    grid-column: 1 / -1;
  }
  .entry-form .or {
    display: none;
  }
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sheet-head .totals {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
  .input,
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
    height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .btn.small {
    min-height: 36px;
  }
  .timer {
    max-width: 100%;
  }
  .hide-sm {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ review fixes */

.rail :focus-visible {
  outline-color: #fff;
}
.due-line {
  color: var(--alert);
  text-decoration: none;
  display: inline-flex;
  gap: 6px;
}
.due-line:hover {
  text-decoration: underline;
  color: var(--alert);
}
.ledger tr:target {
  outline: 2px solid var(--alert);
  outline-offset: -2px;
}
.pad.lg {
  transform: scale(1.5);
  margin: 0 8px;
}

table.ledger.entries {
  table-layout: fixed;
  min-width: 1040px;
}
.ledger.entries td {
  overflow: hidden;
}
.ledger.entries td.contract,
.ledger.entries td.desc {
  text-overflow: ellipsis;
}
.ledger.entries td.desc {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}
.ledger.entries tr.editing td {
  overflow: visible;
}
.ledger.entries tr.editing .input {
  width: 100%;
}
.ledger tr.editing select[name="contract_id"] {
  min-width: 0;
}
.stack-tight {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.pair .input {
  padding: 0 6px;
}
.pair input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
}
.actions .stack-tight .btn {
  width: 100%;
}
.actions .stack-tight .delete {
  margin-top: 10px;
}
.locked-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  vertical-align: middle;
  margin-right: 4px;
}
.locked-ref .icon {
  width: 14px;
  height: 14px;
}

.history-row > td {
  background: var(--stock-2);
  padding: 0 !important;
}
.history {
  border: 1px solid var(--rule);
  background: var(--stock);
  margin: 0 16px 12px 40px;
  padding: 8px 12px 0;
}
.history-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-head button {
  margin-left: auto;
}
.history-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.history-list li {
  display: grid;
  grid-template-columns: 140px 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  font-size: 13px;
}
.history-list .time {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
  .table-wrap {
    border-right: 1px dashed var(--rule);
  }
  .table-wrap table.ledger {
    min-width: 720px;
  }
  .table-wrap table.ledger.entries {
    min-width: 1180px;
  }
  .ledger td:first-child,
  .ledger th:first-child {
    position: sticky;
    left: 0;
    background: var(--stock);
    z-index: 1;
    box-shadow: 1px 0 0 var(--rule);
  }
  .ledger tr.due td:first-child {
    background: var(--alert-wash);
  }
  .ledger tr.day-head td:first-child {
    background: var(--stock-2);
  }
  .sheet-head .totals {
    justify-content: flex-start;
    gap: 24px;
  }
  .sheet-head .totals .figure {
    align-items: flex-start;
  }
  .rail nav a {
    white-space: nowrap;
  }
  .history-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.ledger.entries td.hours {
  overflow: visible;
}
.ledger .actions .slot {
  display: inline-flex;
  justify-content: flex-end;
  min-width: 84px;
  vertical-align: middle;
}

/* ------------------------------------------------------------ phones: rows restack instead of scrolling */

@media (max-width: 640px) {
  .brand {
    position: sticky;
    left: -12px;
    z-index: 2;
    background: var(--rail);
    padding-right: 12px;
  }
  .rail {
    scroll-padding-inline: 132px 16px;
  }
  .table-wrap {
    border-right: 0;
  }
  .table-wrap table.ledger,
  .table-wrap table.ledger.entries {
    min-width: 0;
  }
  .ledger td:first-child,
  .ledger th:first-child {
    position: static;
    box-shadow: none;
  }

  .ledger.entries,
  .ledger.entries tbody,
  .ledger.months,
  .ledger.months tbody,
  .ledger.lines,
  .ledger.lines tbody,
  .ledger.lines-ro,
  .ledger.lines-ro tbody {
    display: block;
    width: 100%;
  }
  .ledger.entries colgroup,
  .ledger.entries thead,
  .ledger.months thead,
  .ledger.lines thead,
  .ledger.lines-ro thead {
    display: none;
  }
  .ledger.entries tr,
  .ledger.months tr,
  .ledger.lines tr,
  .ledger.lines-ro tr {
    display: grid;
    gap: 2px 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--rule);
  }
  .ledger.entries td,
  .ledger.months td,
  .ledger.lines td,
  .ledger.lines-ro td {
    display: block;
    padding: 0 !important;
    border: 0;
    overflow: visible;
    min-width: 0;
  }

  /* entry: person · time · hours / contract / description / linear + actions */
  .ledger.entries tr {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "person time hours" "contract contract contract" "desc desc desc" "linear actions actions";
    align-items: center;
  }
  .ledger.entries td.person { grid-area: person; }
  .ledger.entries td.time { grid-area: time; }
  .ledger.entries td.hours { grid-area: hours; font-weight: 600; }
  .ledger.entries td.contract { grid-area: contract; color: var(--ink-2); font-size: 13px; white-space: normal; }
  .ledger.entries td.desc { grid-area: desc; }
  .ledger.entries td.linear { grid-area: linear; }
  .ledger.entries td.actions { grid-area: actions; }
  .ledger.entries tr.day-head {
    display: flex;
    justify-content: space-between;
    background: var(--stock-2);
  }
  .ledger.entries tr.day-head td:empty { display: none; }
  .ledger.entries tr.editing {
    grid-template-columns: 1fr;
    grid-template-areas: none;
  }
  .ledger.entries tr.editing td { grid-area: auto; }
  .ledger.entries tr.history-row,
  .ledger.entries tr.deleted {
    display: block;
    padding: 0;
  }
  .history {
    margin: 0 0 12px;
  }

  /* month: copy · month+status / hours · value / split / actions */
  .ledger.months tr {
    grid-template-columns: 36px 1fr auto;
    grid-template-areas: "pad month hours" "pad status amount" "split split split" "actions actions actions";
    align-items: center;
  }
  .ledger.months td.padcell { grid-area: pad; align-self: start; }
  .ledger.months td.month-name { grid-area: month; }
  .ledger.months td.statuscell { grid-area: status; }
  .ledger.months td.hours { grid-area: hours; }
  .ledger.months td.amount { grid-area: amount; }
  .ledger.months td.splitcell { grid-area: split; padding-top: 6px !important; }
  .ledger.months td.actions { grid-area: actions; text-align: left; padding-top: 6px !important; }

  /* invoice lines: title / qty · unit · price · amount */
  .ledger.lines tr,
  .ledger.lines-ro tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
  }
  .ledger.lines td:first-child,
  .ledger.lines-ro td:first-child {
    grid-column: 1 / -1;
    margin-bottom: 6px;
  }
  .ledger.lines td .input {
    width: 100% !important;
  }
  .ledger.lines td.amount,
  .ledger.lines-ro td.amount {
    align-self: center;
  }
}

.ledger td.actions > *,
.ledger td.actions .slot > * {
  vertical-align: middle;
}

@media (max-width: 640px) {
  /* a hairline and a rail-coloured edge keep scrolled nav items from reading as part of the brand */
  .brand {
    border-right: 1px solid var(--rail-rule);
    box-shadow: 10px 0 8px -2px var(--rail);
    margin-right: 6px;
  }
  .ledger.sheet-rows,
  .ledger.sheet-rows tbody {
    display: block;
    width: 100%;
  }
  .table-wrap table.ledger.sheet-rows {
    min-width: 0;
  }
  .ledger.sheet-rows thead {
    display: none;
  }
  .ledger.sheet-rows tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "time person hours" "desc desc desc" "linear linear linear";
    gap: 2px 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--rule);
  }
  .ledger.sheet-rows td {
    display: block;
    padding: 0 !important;
    border: 0;
    position: static !important;
    box-shadow: none !important;
  }
  .ledger.sheet-rows td.time { grid-area: time; }
  .ledger.sheet-rows td.person { grid-area: person; }
  .ledger.sheet-rows td.hours { grid-area: hours; font-weight: 600; }
  .ledger.sheet-rows td.desc { grid-area: desc; min-width: 0; }
  .ledger.sheet-rows td.linear { grid-area: linear; }
  .ledger.sheet-rows td.linear:empty { display: none; }
}

/* ------------------------------------------------------------ status marks (replace the copy stack) */

.st-work { --st: var(--st-work); }
.st-active { --st: var(--st-active); }
.st-unbilled { --st: var(--st-unbilled); }
.st-draft { --st: var(--st-draft); }
.st-sevdesk { --st: var(--st-sevdesk); }
.st-open { --st: var(--st-open); }
.st-paid { --st: var(--st-paid); }
.st-cancelled, .st-empty { --st: var(--st-cancelled); }
.ledger tr[class*="st-"] > td:first-child {
  box-shadow: inset 4px 0 0 var(--st);
}
.smark {
  display: inline-block;
  width: 4px;
  height: 14px;
  border-radius: 1px;
  background: var(--st);
  vertical-align: -2px;
  margin-right: 6px;
}
.legend .smark {
  margin-right: 5px;
}
.ledger tr.st-unbilled {
  background: var(--alert-wash);
}
.status.alert,
.status.alert small {
  color: var(--alert);
}

/* ------------------------------------------------------------ clickable rows */

.ledger tr.clickable {
  cursor: pointer;
}
.ledger tr.clickable:hover {
  background: #f1f3f8;
}
.ledger tr.clickable:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.open-hint {
  display: inline-flex;
  color: var(--ink-3);
  vertical-align: middle;
  opacity: 0.5;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
tr.clickable:hover .open-hint {
  opacity: 1;
  transform: translateX(2px);
}
.invref {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

/* ------------------------------------------------------------ collapsible contracts */

details.contract > summary {
  cursor: pointer;
  list-style: none;
}
details.contract > summary::-webkit-details-marker {
  display: none;
}
details.contract:not([open]) > summary {
  border-bottom: 0;
}
details.contract > summary:hover {
  background: var(--stock-2);
}
details.contract > summary .chev {
  align-self: center;
}
details.contract[open] > summary .chev {
  transform: rotate(90deg);
}
.figure b.alert {
  color: var(--alert);
}

/* ------------------------------------------------------------ side panel */

dialog.drawer {
  margin: 0 0 0 auto;
  height: 100dvh;
  max-height: 100dvh;
  width: min(640px, 100vw);
  max-width: 100vw;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--stock);
  color: var(--ink);
  box-shadow: -24px 0 48px rgba(22, 33, 62, 0.18);
}
dialog.drawer[open] {
  animation: drawer-in 220ms var(--ease);
}
@keyframes drawer-in {
  from {
    transform: translateX(32px);
    opacity: 0;
  }
}
dialog.drawer::backdrop {
  background: rgba(26, 26, 46, 0.32);
}
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: var(--stock);
  border-bottom: 1px solid var(--ink);
}
.drawer-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.drawer-title h2 {
  font-size: 18px;
  font-weight: 600;
}
.drawer-content {
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#panel-flash:empty {
  display: none;
}
#panel-flash {
  padding: 12px 20px 0;
}
.panel-status {
  display: flex;
  align-items: center;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding: 10px 12px 10px 14px;
  background: var(--stock-2);
  border: 1px solid var(--rule);
  box-shadow: inset 4px 0 0 var(--st, var(--rule));
}
.panel-status .figure {
  margin-left: auto;
}
.panel-status .figure + .figure {
  margin-left: 0;
}
.panel-status.inline {
  padding: 4px 10px 4px 12px;
}
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}
.panel-section h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
}
.panel-row,
.invoice-card {
  display: grid;
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--stock);
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: inset 4px 0 0 var(--st);
}
.panel-row {
  grid-template-columns: 84px 110px minmax(0, 1fr) 52px;
  gap: 8px;
  padding: 8px 12px 8px 14px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  align-items: baseline;
}
.panel-list li:first-child .panel-row {
  border-top: 0;
}
.panel-row:hover,
.invoice-card:hover {
  background: var(--stock-2);
}
.panel-row .desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invoice-card {
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--rule);
}
.issue-code {
  font: 600 11px/1.5 var(--font);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 4px;
}
.grid-2,
.grid-3 {
  display: grid;
  gap: 12px;
}
.grid-2 {
  grid-template-columns: 1fr 1fr;
}
.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
iframe.pdf {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--rule);
  background: var(--ground);
}
pre.mail {
  white-space: pre-wrap;
  font: 13px/1.5 var(--font);
  background: var(--stock-2);
  border: 1px solid var(--rule);
  padding: 12px;
}
.ledger.compact td {
  padding: 6px 8px;
  font-size: 13px;
}

/* ------------------------------------------------------------ invoicing steps */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--rule);
  background: var(--stock);
}
.steps li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink-2);
  border-left: 1px solid var(--rule);
}
.steps li:first-child {
  border-left: 0;
}
.steps b {
  color: var(--ink);
  font-size: 14px;
}

datalist {
  display: none !important;
}

@media (max-width: 860px) {
  .steps {
    grid-template-columns: 1fr;
  }
  .steps li {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .steps li:first-child {
    border-top: 0;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
  .panel-row {
    grid-template-columns: 70px minmax(0, 1fr) 48px;
  }
  .panel-row .who {
    display: none;
  }
}
@media (max-width: 640px) {
  .ledger.months tr {
    grid-template-columns: 1fr auto;
    grid-template-areas: "month hours" "status amount" "split split" "inv inv";
  }
  .ledger.months td.month-name { grid-area: month; }
  .ledger.months td.invoicecell { grid-area: inv; }
  .ledger.months tr[class*="st-"] > td:first-child { box-shadow: none; }
  .ledger.months tr[class*="st-"] { box-shadow: inset 4px 0 0 var(--st); }
  .ledger.entries tr[class*="st-"] > td:first-child { box-shadow: none; }
  .ledger.entries tr[class*="st-"] { box-shadow: inset 4px 0 0 var(--st); }
}

.tabs a .muted {
  margin-left: 6px;
  font-weight: 500;
}

/* ------------------------------------------------------------ overview: reorder + inactive */

.contracts {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 28px;
  margin-left: -6px;
  color: var(--ink-3);
  cursor: grab;
  border-radius: var(--r);
  touch-action: none;
}
.drag-handle:hover {
  background: var(--ground);
  color: var(--ink);
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-ghost {
  opacity: 0.4;
  outline: 2px dashed var(--ink-3);
}
details.contract.inactive > summary h2,
details.contract.inactive > summary .meta {
  color: var(--ink-3);
}
.contract-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--rule);
  background: var(--stock-2);
}

.send-box textarea {
  min-height: 200px;
  font-size: 13px;
  line-height: 1.5;
}
