@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --walnut: #755D3B;
  --walnut-deep: #5A4529;
  --walnut-dark: #3D2B1A;
  --linen: #E1CEBB;
  --linen-light: #F0E6D8;
  --linen-pale: #F7F0E8;
  --tan: #C4A882;
  --tan-light: #E3D5C1;
  --tan-mid: #A08060;
  --muted: #8B7355;
  --field-border: #CDBFAE;
  --ink: #1E1410;
  --danger: #A40E26;
  --danger-line: #F0C3C8;
  --danger-wash: #FFEBE9;
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--tan);
  --field-focus: 0 0 0 3px rgba(117, 93, 59, 0.15);
  accent-color: var(--walnut);
}

[hidden] { display: none !important; }

a { color: var(--walnut); }
a:where(:hover) { color: var(--walnut-deep); }

:where(:focus-visible) { outline: 2px solid var(--tan); outline-offset: 2px; }

label, .group-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--walnut-dark);
}

input:where(:not([type="checkbox"], [type="radio"], [type="range"])), select, textarea, .field {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
  color: var(--walnut-dark);
  background: #fff;
  border: 1px solid var(--field-border);
  border-radius: 10px;
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

input:where(:not([type="checkbox"], [type="radio"], [type="range"])):where(:focus), select:where(:focus), textarea:where(:focus) {
  outline: none;
  border-color: var(--walnut);
  box-shadow: var(--field-focus);
}

input:where(:disabled, [readonly]), select:where(:disabled), textarea:where(:disabled, [readonly]) { background: var(--linen-pale); color: var(--muted); }

@media (max-width: 640px) {
  input:where(:not([type="checkbox"], [type="radio"], [type="range"])), select, textarea { font-size: 16px; }
}

input:where([type="file"]) { padding: 4px 5px; }
input:where([type="time"], [type="date"], [type="datetime-local"], [type="month"], [type="week"]) { box-sizing: border-box; height: 38px; }
input:where([type="file"])::file-selector-button {
  margin-right: 10px;
  padding: 3px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  color: var(--walnut);
  background: #fff;
  border: 1px solid var(--tan);
  border-radius: 999px;
  cursor: pointer;
}

button, a:where(.btn), label:where(.btn) {
  display: inline-block;
  padding: 8px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: var(--walnut);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

button:where(:hover:not(:disabled)), a:where(.btn:hover), label:where(.btn:hover) { color: #fff; background: var(--walnut-deep); }
button:where(:disabled) { opacity: 0.45; cursor: default; }
button:where(:focus), a:where(.btn:focus) { outline: none; }
button:where(:focus-visible), a:where(.btn:focus-visible) { box-shadow: var(--focus-ring); }

button:where(:has(> svg:first-child, > img:first-child)), a:where(.btn:has(> svg:first-child, > img:first-child)), label:where(.btn:has(> svg:first-child, > img:first-child)) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
:where(button, .btn) > :where(svg:first-child, img:first-child) { flex: none; }
:where(button, .btn) :where(svg:not([fill])) { fill: currentColor; }

.lj-to-top {
  position: fixed;
  right: 2rem;
  bottom: 4.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.25rem;
  letter-spacing: 0.025em;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.lj-to-top.is-shown { opacity: 1; transform: translateY(0); pointer-events: auto; }
.lj-to-top span { display: none; }
@media (min-width: 640px) {
  .lj-to-top { width: auto; height: auto; padding: 0.625rem 1rem; }
  .lj-to-top span { display: inline; }
}

.secondary, .dd-toggle { color: var(--walnut); background: #fff; border-color: var(--tan); }
.secondary:where(:hover:not(:disabled)), .dd-toggle:where(:hover:not(:disabled)) { color: var(--walnut-deep); background: var(--linen-pale); }
.secondary:where(.selected, [aria-pressed="true"]),
.secondary:where(.selected, [aria-pressed="true"]):where(:hover:not(:disabled)) { color: #fff; background: var(--walnut); border-color: var(--walnut); }

.danger { color: var(--danger); background: #fff; border-color: var(--danger-line); }
.danger:where(:hover:not(:disabled)) { color: var(--danger); background: var(--danger-wash); }

.quiet { color: var(--muted); background: transparent; border-color: transparent; }
.quiet:where(:hover:not(:disabled)) { color: var(--walnut-deep); background: var(--linen-pale); }

.field:where(:hover:not(:disabled)) { color: var(--walnut-dark); background: #fff; border-color: var(--tan); }

.small { padding: 3px 12px; font-size: 13px; }

.block { display: block; width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.icon-btn > :where(svg, img) { width: 18px; height: 18px; }

.back-to-top {
  position: fixed;
  right: 2rem;
  bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  padding: 10px 16px;
  letter-spacing: 0.025em;
  box-shadow: 0 10px 15px -3px rgba(30, 20, 16, 0.18), 0 4px 6px -4px rgba(30, 20, 16, 0.18);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s, background-color 0.5s;
}
.back-to-top.shown { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 639px) {
  .back-to-top { width: 44px; height: 44px; padding: 0; }
  .back-to-top > span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .back-to-top { transition: none; } }
html.lj-theo .lj-to-top, html.lj-theo .back-to-top { right: calc(2rem + 5rem); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--tan-light); cursor: pointer; transition: background 0.2s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--walnut); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus-ring); }
.switch input:disabled + span { opacity: 0.5; cursor: default; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.row-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }

.dtp { position: relative; }
.dtp-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.dtp.open .dtp-field { border-color: var(--walnut); box-shadow: var(--field-focus); }
.dtp-field .ph { color: var(--muted); }
.dtp-field svg { flex: none; color: var(--muted); }
.dtp-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 280px; padding: 12px; border-radius: 12px; background: #fff; border: 1px solid var(--tan-light); box-shadow: 0 16px 40px rgba(30, 20, 16, 0.22); text-align: left; }
.dtp-pop button { font-weight: 400; }
.dtp.up .dtp-pop { top: auto; bottom: calc(100% + 6px); }
.dtp.right .dtp-pop { left: auto; right: 0; }
.dtp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; font-size: 13.5px; color: var(--walnut-dark); }
.dtp-head button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--walnut); font-size: 16px; }
.dtp .dtp-head button:hover:not(:disabled) { background: var(--linen-light); color: var(--walnut-deep); }
.dtp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12.5px; }
.dtp-grid .dow { color: var(--muted); font-size: 11px; padding: 4px 0; }
.dtp-grid button { width: 100%; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--walnut-dark); font: inherit; }
.dtp .dtp-grid button:hover:not(:disabled) { background: var(--linen-light); color: var(--walnut-dark); }
.dtp .dtp-grid button.sel:hover:not(:disabled) { background: var(--walnut-deep); color: #fff; }
.dtp-grid button.today { box-shadow: inset 0 0 0 1px var(--tan); }
.dtp-grid button.sel { background: var(--walnut); color: #fff; }
.dtp-time { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--linen-light); }
.dtp-time-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dtp-spins { display: flex; align-items: center; gap: 6px; }
.dtp-spins .colon { font-size: 20px; color: var(--muted); padding-bottom: 2px; }
.spin { display: flex; flex-direction: column; align-items: center; width: 48px; border: 1px solid var(--tan-light); border-radius: 10px; background: #fff; overflow: hidden; }
.spin:focus-within { border-color: var(--tan); box-shadow: 0 0 0 3px rgba(196, 168, 130, 0.25); }
.dtp .spin button { width: 100%; height: 20px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--tan-mid); font-size: 10px; line-height: 1; }
.dtp .spin button:hover:not(:disabled) { background: var(--linen-pale); color: var(--walnut-deep); }
.spin input { width: 100%; padding: 2px 0; border: 0; outline: none; box-shadow: none; background: transparent; text-align: center; font: inherit; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--walnut-dark); }
.dtp-foot { display: flex; justify-content: space-between; margin-top: 10px; }
.dtp .dtp-foot .dtp-clear { background: transparent; color: var(--muted); }
.dtp .dtp-foot .dtp-clear:hover:not(:disabled) { background: var(--linen-pale); color: var(--walnut-deep); }
.dtp-done { margin-left: auto; }

.lj-dialog { margin: auto; width: min(26rem, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 22px 24px 20px; border: 1px solid var(--tan-light); border-radius: 16px; background: #fffdfa; color: var(--walnut-dark); font-family: var(--font-body); text-align: left; box-shadow: 0 24px 60px rgba(58, 44, 28, 0.3); opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity 160ms ease, transform 160ms ease; }
.lj-dialog.open { opacity: 1; transform: none; }
.lj-dialog::backdrop { background: rgba(58, 44, 28, 0.5); }
.lj-dialog h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 1.15rem; font-weight: 400; line-height: 1.3; color: var(--walnut); }
.lj-dialog.danger h2 { color: var(--danger); }
.lj-dialog-message { margin: 0 0 4px; font-size: 14px; line-height: 1.6; color: var(--walnut-dark); }
.lj-dialog label { display: block; margin: 14px 0 6px; }
.lj-dialog-optional { font-weight: 400; color: var(--muted); }
.lj-dialog textarea, .lj-dialog input { width: 100%; box-sizing: border-box; }
.lj-dialog textarea { resize: vertical; min-height: 5.5rem; }
.lj-dialog-actions { justify-content: flex-end; margin-top: 18px; }
@media (prefers-reduced-motion: reduce) { .lj-dialog { transition: none; transform: none; } }

.error { margin: 12px 0; padding: 10px 12px; font-size: 14px; color: #8b1a1a; background: #ffeef0; border: 1px solid #f0b8bd; border-radius: 4px; }
.notice { margin: 12px 0; padding: 10px 12px; font-size: 14px; color: #1f4620; background: #eefbf0; border: 1px solid #b4e0bc; border-radius: 4px; }
body:has(.page) #error, body:has(.page) #notice, html.lj-framed #error.error, html.lj-framed #notice.notice { position: fixed; top: calc(72px + 12px); left: 50%; z-index: 45; width: min(640px, calc(100% - 32px)); margin: 0; transform: translateX(-50%); box-shadow: 0 8px 24px rgba(30, 20, 16, 0.18); }
#notice { transition: opacity 0.6s ease; }
#notice.banner-fading { opacity: 0; }
.error.closable { position: relative; padding-right: 40px; }
.error .banner-close { position: absolute; top: 50%; right: 6px; width: 28px; height: 28px; margin: 0; padding: 0; transform: translateY(-50%); border: 0; border-radius: 50%; background: transparent; color: #8b1a1a; font-size: 20px; line-height: 28px; text-align: center; cursor: pointer; }
.error .banner-close:hover { background: rgba(139, 26, 26, 0.1); color: #8b1a1a; }
body:has(.page) #error:not([hidden]) ~ #notice, html.lj-framed #error.error:not([hidden]) ~ #notice.notice { top: calc(72px + 12px + 3.5rem); }
.lj-invoice { color: var(--walnut-dark); font-size: 14px; line-height: 1.5; }
.lj-invoice header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.lj-invoice h3 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; color: var(--walnut); }
.lj-invoice-from, .lj-invoice-to, .lj-invoice-period { font-size: 13px; color: var(--muted); }
.lj-invoice-company { color: var(--walnut-dark); font-weight: 500; }
.lj-invoice-meta { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; font-size: 13px; align-content: start; }
.lj-invoice-meta dt { color: var(--muted); }
.lj-invoice-meta dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.lj-invoice-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lj-invoice-to { margin-bottom: 6px; }
.lj-invoice table { width: 100%; border-collapse: collapse; margin: 12px 0 6px; }
.lj-invoice td { padding: 7px 0; border-top: 1px solid var(--linen-light); }
.lj-invoice td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.lj-invoice tr.total td { font-weight: 600; border-top: 2px solid var(--tan-light); }
.lj-invoice tr.gst td { border-top: 0; padding-top: 0; font-size: 12px; color: var(--muted); }
.lj-invoice tr.paid td { border-top: 0; padding-top: 2px; }
.lj-invoice tr.owing td { font-weight: 600; color: var(--walnut); border-top: 2px solid var(--walnut); padding-top: 9px; }
.lj-invoice-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.lj-invoice-bank { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--tan-light); border-radius: 10px; background: var(--linen-pale); }
.lj-invoice-bank h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--walnut); }
.lj-invoice-bank dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 13px; }
.lj-invoice-bank dt { color: var(--muted); }
.lj-invoice-bank dd { margin: 0; font-variant-numeric: tabular-nums; }
.lj-invoice-bank p { margin: 8px 0 0; font-size: 12px; color: var(--walnut-dark); }
@media print {
  body.lj-printing * { visibility: hidden; }
  body.lj-printing .lj-print-target, body.lj-printing .lj-print-target * { visibility: visible; }
  body.lj-printing .lj-print-target { position: absolute; inset: 0 auto auto 0; width: 100%; box-shadow: none; }
  body.lj-printing .lj-invoice-actions { display: none; }
}
