:root {
  --red: #c4231b;
  --red-dark: #9e1a14;
  --gold: #f2a900;
  --ink: #1f1a17;
  --ink-2: #5b524c;
  --muted: #8a8079;
  --line: #ebe3da;
  --bg: #fbf7f2;
  --card: #ffffff;
  --green: #1f8a4c;
  --green-bg: #e7f5ec;
  --amber: #b66a00;
  --amber-bg: #fff3dc;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --blue: #1b5fae;
  --blue-bg: #e8f0fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 26, 23, 0.06), 0 4px 14px rgba(31, 26, 23, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { min-height: 100vh; line-height: 1.4; font-size: 16px; }
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
a { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.wrap-ok { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; cursor: pointer;
  background: #efe8e1; color: var(--ink); min-height: 44px; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-dark); }
.btn.green { background: var(--green); color: #fff; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.outline { background: #fff; border: 1.5px solid var(--line); }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: 14px; border-radius: 10px; }
.icon-btn { border: 0; background: #efe8e1; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; min-height: 44px;
}
.input:focus { outline: none; border-color: var(--red); }
textarea.input { min-height: 70px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #efe8e1; color: var(--ink-2); }
.pill.new { background: var(--amber-bg); color: var(--amber); }
.pill.accepted, .pill.paid { background: var(--green-bg); color: var(--green); }
.pill.rejected, .pill.cancelled, .pill.void { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--blue-bg); color: var(--blue); }
.pill.gold { background: #fff1c7; color: #8a5a00; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }

.backdrop { position: fixed; inset: 0; background: rgba(20, 15, 12, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up 0.2s ease; }
.sheet > * + * { margin-top: 12px; }
.sheet.wide { max-width: 760px; }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 100; max-width: 90vw; font-weight: 600; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }
#toast.ok { background: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
table.grid td.r, table.grid th.r { text-align: right; }
