/* Praxis house style (Tutto). Mobile first; 44px minimum touch targets. */
:root {
  --bg: #FAF9F6;
  --text: #1F1F1F;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --muted: #E9E7E3;
  --text-2: #4B5563;
  --text-3: #6B7280;
  --amber: #DB7400;
  --amber-text: #B45F00;
  --amber-soft: #FDF1E3;
  --red: #B42318;
  --red-soft: #FEF3F2;
  --green: #067647;
  --green-soft: #ECFDF3;
  --radius: 12px;
  --radius-input: 10px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { font-family: Roboto, Inter, system-ui, sans-serif; font-weight: 800; line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
a { color: var(--amber-text); }
p { margin: 0 0 12px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter); border-bottom: 1px solid var(--border); background: var(--card);
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-family: Roboto, sans-serif; font-weight: 900; font-size: 19px; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px;
  color: var(--text-2); text-decoration: none; border-radius: var(--radius-input); font-size: 15px;
}
.topbar nav a.on { color: var(--text); background: var(--muted); font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: var(--gutter); }
main.wide { max-width: 1100px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }
.center { text-align: center; }

.next-number { text-align: center; padding: 20px 16px; }
.next-number .label { color: var(--text-2); font-size: 18px; margin-bottom: 4px; }
.next-number .num {
  font-family: Roboto, sans-serif; font-weight: 900; font-size: clamp(64px, 22vw, 112px);
  letter-spacing: 0.04em; line-height: 1; font-variant-numeric: tabular-nums;
}
.write-hint { font-size: 20px; text-align: center; margin: 4px 0 16px; }
.write-hint strong { font-family: Roboto, sans-serif; font-weight: 900; font-size: 26px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 12px 18px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font: 600 18px/1.2 Inter, system-ui, sans-serif; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn + .btn, .btn + form, form + .btn, form + form { margin-top: 10px; }
/* Amber background always carries near-black text: white on #DB7400 fails contrast. */
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1F1F1F; }
.btn.primary:active { background: #C46800; }
.btn.small { min-height: 44px; font-size: 15px; width: auto; display: inline-flex; padding: 8px 14px; }
.btn.danger { color: var(--red); }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--card);
  color: var(--text); font: 17px/1.3 Inter, system-ui, sans-serif; /* 16px+ stops iOS zooming */
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, #6B7280 50%), linear-gradient(135deg, #6B7280 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px;
}
input[type=date] { display: block; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
.amount-input { font-size: 24px !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber-text); border: 1px solid #F5D3A8; vertical-align: middle;
}
.badge.grey { background: var(--muted); color: var(--text-2); border-color: var(--border); }
.badge.red { background: var(--red-soft); color: var(--red); border-color: #FECDCA; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: #ABEFC6; }

.notice { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--card); }
.notice.ok { border-color: #ABEFC6; background: var(--green-soft); }
.notice.warn { border-color: var(--amber); background: var(--amber-soft); }
.notice.bad { border-color: #FECDCA; background: var(--red-soft); }
.error { color: var(--red); font-weight: 600; }

.photo { display: block; width: 100%; max-height: 52vh; object-fit: contain; background: var(--muted); border-radius: var(--radius); border: 1px solid var(--border); }
.spinner { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 24px; color: var(--text-2); }
.spinner::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--muted); border-top-color: var(--amber); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 10px; background: var(--muted); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; width: 0; background: var(--amber); transition: width 0.2s; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); min-height: 44px; }
.list li:first-child { border-top: 0; }
.list a.row { display: flex; justify-content: space-between; gap: 12px; width: 100%; color: var(--text); text-decoration: none; }
.mono { font-variant-numeric: tabular-nums; font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.tile .k { font-size: 13px; color: var(--text-3); }
.tile .v { font-family: Roboto, sans-serif; font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }
.tile.alert { border-color: var(--amber); }

.month-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.month-switch h1 { margin: 0; text-align: center; flex: 1; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.slips { width: 100%; border-collapse: collapse; font-size: 15px; }
table.slips th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 13px; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.slips td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.slips td.num, table.slips th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.slips select { min-height: 40px; font-size: 15px; min-width: 180px; }
table.slips tr.saved td { background: var(--green-soft); transition: background 1s; }

.flag { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.flag:first-of-type { border-top: 0; }
.flag .msg { flex: 1 1 240px; }
.flag form.void { display: flex; gap: 6px; flex-wrap: wrap; }
.flag form.void input { min-height: 44px; width: 200px; }

details.more summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text-2); font-weight: 600; }
.hidden { display: none !important; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }

@media (min-width: 760px) {
  .tiles { gap: 16px; }
  .tile .v { font-size: 28px; }
}

.biz-switch select { min-height: 44px; font-family: Roboto, sans-serif; font-weight: 800; font-size: 17px; max-width: 52vw; border-color: var(--amber); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.biz-chip { display: inline-block; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--muted); color: var(--text); }
