:root {
  --bg: #f5f1e8;
  --card: #ffffff;
  --fill: #f3efe5;
  --fill-strong: #ebe5d6;
  --line: rgba(70, 58, 20, 0.10);
  --gold: #7a6b33;
  --gold-deep: #6b5e2c;
  --gold-tint: #f1ead3;
  --ink: #1d1d1f;
  --muted: #6e6a5e;
  --slate: #23282f;
  --slate-text: #f4efe3;
  --slate-muted: #a9a595;
  --sun: #dccb8c;
  --error: #b3261e;
  --ok: #2e6b34;
  --ok-tint: #e2efdd;
  --shadow: 0 1px 2px rgba(40, 30, 0, 0.04), 0 10px 30px rgba(70, 58, 20, 0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Hebrew", system-ui, "Segoe UI", "Heebo", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}
.wrap { max-width: 34rem; margin: 0 auto; padding: 2.5rem 1rem 1rem; }
.wrap.wide { max-width: 44rem; padding-bottom: 3rem; }

/* header */
header { text-align: center; margin-bottom: 1.75rem; }
.brand { letter-spacing: 0.3em; color: var(--gold); font-size: 0.75rem; font-weight: 600; margin-inline-start: 0.3em; }
h1 { font-size: clamp(2rem, 8vw, 2.75rem); line-height: 1.1; letter-spacing: -0.02em; font-weight: 700; margin: 0.6rem 0 0.5rem; }
header p { margin: 0 auto; max-width: 24rem; color: var(--muted); font-size: 1.0625rem; line-height: 1.45; }

/* cards */
.card { background: var(--card); border-radius: 1.375rem; padding: 1.375rem 1.25rem; margin-bottom: 0.875rem; box-shadow: var(--shadow); }
.card h2 { font-size: 1.1875rem; line-height: 1.25; letter-spacing: -0.01em; font-weight: 650; margin: 0 0 1rem; }
.highlight { background: var(--gold-tint); box-shadow: none; }

/* fields */
label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--muted); margin: 1rem 0 0.375rem; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=tel], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 3.25rem; padding: 0.75rem 0.875rem; font: inherit; font-size: 1.0625rem; color: var(--ink);
  background: var(--fill); border: 1px solid transparent; border-radius: 0.875rem;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder { color: #a8a290; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236e6a5e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 0.875rem center; padding-inline-end: 2.25rem;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; background-color: #fff; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(138, 122, 60, 0.18); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.hint { font-size: 0.8125rem; color: var(--muted); margin: 0.375rem 0 0; }
.err { font-size: 0.8125rem; font-weight: 500; color: var(--error); margin: 0.375rem 0 0; display: none; }
.err.show { display: block; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }

/* selectable rows */
.checks { border-radius: 0.875rem; background: var(--fill); overflow: hidden; }
.checks label {
  display: flex; align-items: center; gap: 0.75rem; margin: 0; padding: 0.875rem; min-height: 3.25rem;
  font-size: 1.0625rem; font-weight: 400; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--line); transition: background 100ms ease;
}
.checks label:last-child { border-bottom: 0; }
.checks label:active { background: var(--fill-strong); }
.checks input {
  -webkit-appearance: none; appearance: none; flex: none; width: 1.5rem; height: 1.5rem; margin: 0; border-radius: 50%;
  border: 1.5px solid #c4bca4; background: #fff center / 0.8rem no-repeat; transition: background-color 150ms ease, border-color 150ms ease, transform 150ms var(--ease);
}
.checks input:checked {
  border-color: var(--gold); background-color: var(--gold);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1.5 5.2l3 3 6-6.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.checks input:active { transform: scale(0.9); }
.checks input:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(138, 122, 60, 0.25); }

.lockbadge { display: flex; align-items: center; gap: 0.625rem; font-size: 1.1875rem; font-weight: 650; letter-spacing: -0.01em; color: var(--gold-deep); }
.lockbadge::before {
  content: ""; flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--gold) center / 0.9rem no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1.5 5.2l3 3 6-6.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.highlight .hint { color: var(--gold-deep); font-size: 0.9375rem; margin-top: 0.5rem; }

/* buttons */
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 3.5rem; padding: 0 1.25rem;
  border-radius: 1rem; background: var(--gold); color: #fff; font-size: 1.0625rem; font-weight: 600; text-decoration: none;
  transition: transform 100ms ease-out, background 150ms ease, opacity 150ms ease;
}
.btn:hover { background: var(--gold-deep); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(138, 122, 60, 0.35); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.small { width: auto; min-height: 3.25rem; padding: 0 1.5rem; }
.btn.quiet { background: var(--fill); color: var(--muted); }
.btn.quiet:hover { background: var(--fill-strong); }
.btn.sun { background: var(--sun); color: var(--slate); }
.btn.sun:hover { background: #e6d79d; }
.btn.ghost { background: rgba(255, 255, 255, 0.08); color: var(--slate-text); font-weight: 500; margin-top: 0.625rem; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.14); }
button.link { min-height: 2.75rem; padding: 0 0.625rem; color: var(--gold-deep); font-size: 0.9375rem; font-weight: 500; border-radius: 0.625rem; transition: background 100ms ease; }
button.link:active { background: var(--fill); }

/* floating call to action */
.cta {
  position: sticky; bottom: 0; z-index: 3; margin: 0.5rem -1rem 0; padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: rgba(245, 241, 232, 0.72); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 0.75rem); mask-image: linear-gradient(to bottom, transparent, #000 0.75rem);
}

/* summary */
.summary { background: var(--slate); color: var(--slate-text); border-radius: 1.5rem; padding: 1.5rem 1.25rem 1.25rem; display: none; box-shadow: 0 20px 50px rgba(20, 24, 30, 0.25); margin-bottom: 2rem; }
.summary.show { display: block; animation: materialize 450ms var(--ease) both; }
@keyframes materialize { from { opacity: 0; transform: scale(0.96) translateY(0.5rem); filter: blur(8px); } to { opacity: 1; transform: none; filter: blur(0); } }
.summary h2 { margin: 0 0 1rem; font-size: 1.5rem; letter-spacing: -0.02em; line-height: 1.15; font-weight: 700; color: #fff; }
.summary dl { margin: 0; }
.summary dl > div, .summary dt, .summary dd { margin: 0; }
.summary dl { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; font-size: 0.9375rem; }
.summary dt { color: var(--slate-muted); padding: 0.5rem 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.summary dd { padding: 0.5rem 0; border-top: 1px solid rgba(255, 255, 255, 0.08); overflow-wrap: anywhere; }
.summary dt:first-of-type, .summary dt:first-of-type + dd { border-top: 0; }
.summary .btn.quiet { background: var(--fill); color: var(--muted); }
.btn.quiet:hover { background: var(--fill-strong); }
.btn.sun { margin-top: 1.25rem; }
.summary .note { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--slate-muted); text-align: center; }

/* dashboards */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; margin-bottom: 0.875rem; }
.stat { background: var(--card); border-radius: 1.25rem; padding: 1rem 0.75rem; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: clamp(1.625rem, 7vw, 2.25rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.8125rem; font-weight: 500; color: var(--muted); margin-top: 0.25rem; }
.stat.key { background: var(--slate); box-shadow: 0 10px 30px rgba(20, 24, 30, 0.2); }
.stat.key .n { color: var(--sun); }
.stat.key .l { color: var(--slate-muted); }
.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.bar h2 { margin: 0; }
.lead { border-top: 1px solid var(--line); padding: 1rem 0; }
.lead:first-child { border-top: 0; padding-top: 0.25rem; }
.lead:last-child { padding-bottom: 0.25rem; }
.lead .top { display: flex; align-items: center; gap: 0.75rem; }
.avatar { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--gold-tint); color: var(--gold-deep); display: flex; align-items: center; justify-content: center; font-size: 1.125rem; font-weight: 650; }
.lead .info { flex: 1; min-width: 0; }
.lead .who { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.lead .meta { font-size: 0.875rem; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.pill { flex: none; font-size: 0.8125rem; font-weight: 600; padding: 0.25rem 0.625rem; border-radius: 999px; white-space: nowrap; }
.pill.new { background: var(--gold-tint); color: var(--gold-deep); }
.pill.won { background: var(--ok-tint); color: var(--ok); }
.pill.lost { background: #eeece6; color: var(--muted); }
.money { display: inline-block; margin: 0.625rem 3.5rem 0 0; font-size: 0.9375rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.money b { font-weight: 650; color: var(--ok); }

.edit { margin-top: 0.875rem; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; background: var(--fill); border-radius: 0.875rem; }
.seg button { min-height: 2.75rem; border-radius: 0.6875rem; font-size: 0.9375rem; font-weight: 500; color: var(--muted); transition: background 200ms var(--ease), color 150ms ease, transform 100ms ease-out; }
.seg button:active { transform: scale(0.97); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(40, 30, 0, 0.14), 0 0 0 0.5px rgba(40, 30, 0, 0.04); }
.seg button.on[data-s="סגר"] { color: var(--ok); }
.seg button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(138, 122, 60, 0.35); }
.amounts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.625rem; align-items: end; margin-top: 0.75rem; }
.amounts label { margin: 0 0 0.25rem; font-size: 0.8125rem; }
.saved { font-size: 0.8125rem; font-weight: 500; color: var(--ok); min-height: 1.25rem; margin-top: 0.375rem; }
.saved.bad { color: var(--error); }
.saved.todo { color: var(--gold-deep); }
.empty { color: var(--muted); font-size: 1.0625rem; text-align: center; padding: 2rem 0; margin: 0; }
.login { max-width: 24rem; margin-inline: auto; }
.login .btn { margin-top: 1rem; }

@media (max-width: 30rem) {
  .amounts { grid-template-columns: 1fr 1fr; }
  .amounts .btn { grid-column: 1 / -1; width: 100%; }
  .money { margin-inline-start: 0; }
}
@media (max-width: 22rem) { .row { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .summary.show { animation: fade 200ms ease both; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .btn, .seg button, .checks input { transition: none; }
  .btn:active, .seg button:active, .checks input:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .cta { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(0, 0, 0, 0.35); --muted: #45423a; }
  input[type=text], input[type=tel], input[type=password], input[type=number], select, textarea, .checks, .seg { border: 1px solid #45423a; }
  .cta { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* review pass */
input::placeholder, textarea::placeholder { color: #7d7868; }
input[type=text], input[type=tel], input[type=password], input[type=number], select, textarea { border-color: rgba(70, 58, 20, 0.16); scroll-margin-block: 1rem 6rem; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.brand { color: var(--gold-deep); margin-inline-start: 0; margin-left: 0.3em; }
h1, header p { text-wrap: balance; }
.lead .meta { text-wrap: pretty; }
[aria-invalid="true"] { border-color: var(--error); background-color: #fbf1ef; }
.hint:has(+ .err.show) { display: none; }
select:has(option[value=""]:checked) { color: var(--muted); }
.checks label:has(input:checked) { background: var(--gold-tint); font-weight: 500; }
.checks input { border-color: #8a826b; }
textarea { resize: none; field-sizing: content; max-height: 14rem; }
.cta { -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
@media (max-height: 30rem) { .cta { position: static; } }
.btn:focus-visible, .seg button:focus-visible, .checks input:focus-visible, button.link:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; box-shadow: none; }
.summary .btn:focus-visible { outline-color: var(--sun); }
.summary h2:focus { outline: none; }
.summary dl { column-gap: 0; }
.summary dt { padding-inline-end: 1rem; }
.summary dd { overflow-wrap: break-word; }
.summary .note { margin: 1.25rem 0 0.75rem; color: var(--slate-text); font-size: 1rem; text-align: start; }
.summary .btn.sun { margin-top: 0; }
.btn.ghost { background: none; min-height: 2.75rem; color: var(--slate-muted); margin-top: 0.375rem; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.lead .top { align-items: flex-start; }
.pill { margin-top: 0.125rem; }
.amounts .btn.quiet { background: transparent; box-shadow: inset 0 0 0 1px rgba(70, 58, 20, 0.2); color: var(--muted); }
.saved { min-height: 0; }
.saved:empty { display: none; }

.logo { display: block; width: 6rem; height: 6rem; border-radius: 50%; margin: 0 auto 1rem; box-shadow: 0 12px 34px rgba(70, 58, 20, 0.22); }

/* statuses, manual add, delete */
.seg { grid-template-columns: repeat(4, 1fr); }
.seg button.on[data-s="סורב"] { color: #9a5b12; }
.pill.refused { background: #fbeedb; color: #9a5b12; }
.edit:not(.money) .amounts { grid-template-columns: 1fr; }
.edit:not(.money) .amounts > div { display: none; }
.edit:not(.money) .amounts .btn.quiet { display: none; }
.edit.refused .amounts > div:first-child { display: none; }
.edit.refused .amounts { grid-template-columns: 1fr auto; }
.rowtools { display: flex; justify-content: flex-end; margin-top: 0.25rem; }
button.link.danger { color: var(--error); font-size: 0.875rem; }
.addbox { background: var(--fill); border-radius: 1rem; padding: 1rem; margin-bottom: 1rem; }
.addbox input { background: #fff; }
.addactions { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; }
@media (max-width: 30rem) { .edit.refused .amounts { grid-template-columns: 1fr; } }
