:root {
  --paper: #f4efe6;
  --ink: #1c1915;
  --muted: #5f564c;
  --line: #ddd4c6;
  --stamp: #9a3412;
  --field: #fffdf8;
  --soft: #f3e7dc;
  --shadow: 0 16px 40px rgba(48, 32, 14, 0.08);
  color: var(--ink);
  font-family: "Noto Sans", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Hebrew", sans-serif;
  font-size: 17px;
  background:
    radial-gradient(circle at 8% -8%, #f6d9c6, transparent 34%),
    var(--paper);
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; }

button, input, select, textarea { font: inherit; color: inherit; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px 6vw 4px;
}

.mark {
  margin: 0;
  letter-spacing: 0.22em;
  font-size: 12px;
  font-weight: 700;
  color: var(--stamp);
}

.tagline {
  margin: 8px 0 0;
  font-family: "Noto Serif", serif;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.lang-box { position: relative; width: min(280px, 100%); }

.kicker, .field > span, .mini > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field em, .opt {
  font-style: normal;
  color: #8a7d70;
  font-size: 13px;
}
.field em::before { content: "· "; }

#lang-open, input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}

#lang-open {
  text-align: start;
  cursor: pointer;
}

textarea { min-height: 76px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid #e7b89a;
  border-color: var(--stamp);
}

.lang-pop {
  position: absolute;
  z-index: 4;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  width: min(340px, 86vw);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
}

#lang-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
}

#lang-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: start;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

#lang-list button[aria-selected="true"],
#lang-list button:hover { background: var(--soft); }

#lang-list small { color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap: 22px;
  padding: 18px 6vw 40px;
  align-items: start;
}

.panel, .sheet {
  background: rgba(255, 252, 246, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel { padding: 8px 22px 22px; }

section { padding: 18px 0; border-bottom: 1px solid var(--line); }

h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--stamp);
  font-size: 14px;
}

.help, .hint { margin: 0 0 14px; color: var(--muted); line-height: 1.4; }
.hint { margin-top: 8px; }

.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 0.8fr 1fr 0.7fr; margin-top: 14px; }
.field { display: block; margin-bottom: 12px; }

.line {
  display: grid;
  grid-template-columns: 1.6fr 0.55fr 0.75fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.mini { display: block; }

.ghost, .primary, .secondary, .icon-remove {
  border-radius: 999px;
  min-height: 48px;
  padding: 10px 16px;
  cursor: pointer;
}

.ghost, .secondary, .icon-remove {
  background: transparent;
  border: 1px solid var(--line);
}

.icon-remove {
  width: 48px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.primary {
  background: var(--ink);
  color: #f6f1e6;
  border: 0;
  font-weight: 700;
}

details { padding: 8px 0 16px; }
summary {
  cursor: pointer;
  color: var(--stamp);
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}
details .field { margin-top: 12px; }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 14px;
  border-radius: 18px;
  background: #fffaf3;
  border: 1px solid var(--line);
}

.due-line { margin: 0; }
.due-line strong {
  display: block;
  font-family: "Noto Serif", serif;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.action-buttons { display: flex; gap: 8px; }

.sheet {
  position: sticky;
  top: 16px;
  padding: 28px 28px 28px 36px;
}

.sheet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  border-radius: 22px 0 0 22px;
  background: var(--stamp);
}

.empty {
  margin: 48px 0;
  font-family: "Noto Serif", serif;
  font-size: 28px;
  line-height: 1.25;
}

.sheet h2 {
  font-family: "Noto Serif", serif;
  font-size: 40px;
  margin: 8px 0;
}

.who { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0; }
.who p, .meta p { margin: 0; white-space: pre-wrap; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-weight: 600; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 4px; }
.num { text-align: right; }
.totals { margin-left: auto; width: min(260px, 100%); }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.grand { font-family: "Noto Serif", serif; font-size: 22px; }
.thanks { color: var(--muted); }
.pay a { color: var(--stamp); }

[dir="rtl"] .sheet::before { left: auto; right: 0; border-radius: 0 22px 22px 0; }
[dir="rtl"] .sheet { padding: 28px 36px 28px 28px; }
[dir="rtl"] .num, [dir="rtl"] th.num { text-align: left; }

@media (max-width: 980px) {
  .layout, .top { display: block; }
  .lang-box { width: 100%; margin-top: 16px; }
  .grid-2, .grid-3, .line { grid-template-columns: 1fr 1fr; }
  .line .grow { grid-column: 1 / -1; }
  .sheet { position: static; margin-top: 16px; }
  .actions, .action-buttons { display: block; }
  .primary, .secondary, .ghost { width: 100%; margin-top: 8px; }
}

@media print {
  body { background: white; }
  .top, .panel { display: none; }
  .layout { display: block; padding: 0; }
  .sheet { box-shadow: none; border: 0; }
  #pv-empty { display: none; }
  #pv-body { display: block !important; }
}
