/* Wattle Notes app styles (own theme, distinct from Billfold). */
@font-face { font-family: "Lora"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/lora-latin.woff2) format("woff2"); }
:root {
  /* Wattle Notes theme: airy off-white, eucalyptus primary, golden wattle accent, charcoal-green ink. Lora headings + Outfit body. */
  --ink: #1f2d27; --ink-2: #36463f;
  --pine: #3d6b5c; --pine-2: #30574a; --pine-soft: #6f9886;
  --paper: #f7f8f3; --paper-2: #edf2eb; --card: #ffffff;
  --line: #dfe6de; --line-strong: #c6d2c8;
  --copper: #9a4a2a; --wattle: #f2c12e; --wattle-2: #e3ae17; --gold: #8a6300; --sage: #dce8e0;
  --muted: #56655e;
  --ring: 0 0 0 3px rgba(61, 107, 92, 0.45);
  --shadow: 0 1px 2px rgba(31,45,39,.05), 0 18px 44px rgba(31,45,39, 0.08);
  font-family: "Outfit", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
img { max-width: 100%; }
a { color: var(--pine); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; z-index: 40; text-decoration: none; }
.skip:focus { top: 12px; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 6;
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 12px 28px;
  background: rgba(247, 248, 243, 0.9);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; border-radius: 12px; min-width: 0; }
.mark { width: 40px; height: 40px; display: block; flex: none; }
.mark img { width: 40px; height: 40px; display: block; border-radius: 10px; }
.brand h1 { margin: 0; font-family: "Lora", Georgia, serif; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.84rem; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Tabs: top bar on desktop, bottom bar on phones */
.tabs {
  position: sticky; top: 65px; z-index: 5;
  display: flex; gap: 4px; justify-content: center;
  padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.tab {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: transparent;
  border-radius: 999px; padding: 8px 16px; min-height: 40px; color: var(--muted); font-weight: 500; font-size: .95rem;
  transition: background-color .15s ease, color .15s ease;
}
.tab svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tab:hover { color: var(--ink); background: rgba(31,45,39,.04); }
.tab.on { background: var(--sage); color: var(--pine-2); box-shadow: inset 0 -2px 0 var(--wattle-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; border: 1px solid var(--line-strong); background: var(--card);
  border-radius: 999px; padding: 8px 18px; font-size: 0.94rem; font-weight: 500; line-height: 1.2; color: var(--ink);
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pine); color: #ffffff; border-color: var(--pine); }
.btn.primary:hover { background: var(--pine-2); border-color: var(--pine-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--copper); border-color: rgba(154, 74, 42, 0.35); background: transparent; }
.btn.danger:hover { background: rgba(154, 74, 42, 0.07); border-color: var(--copper); }
.pro-btn { border-color: var(--pine); color: var(--pine); }
.pro-btn.is-pro { background: var(--pine); color: #ffffff; }
a.btn { text-decoration: none; }
.btn.buy { background: var(--wattle); border-color: var(--wattle-2); color: var(--ink); font-weight: 600; }
.btn.buy:hover { background: var(--wattle-2); border-color: #c9960c; color: var(--ink); }
.btn.is-disabled, .btn[aria-disabled="true"] { background: var(--card); border-color: var(--line); color: var(--muted); cursor: not-allowed; pointer-events: none; }
label.btn { cursor: pointer; }
label.btn:focus-within { box-shadow: var(--ring); }
.linkish { border: 0; background: none; padding: 0; color: var(--pine); text-decoration: underline; text-underline-offset: .15em; }
.back { display: inline-flex; align-items: center; min-height: 40px; border: 0; background: none; padding: 0; margin: 0 0 2px; color: var(--muted); font-size: .92rem; border-radius: 6px; }
.back:hover { color: var(--ink); }

/* Views */
.main { max-width: 1280px; margin: 0 auto; padding: 24px 28px 40px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h2 { font-family: "Lora", Georgia, serif; font-size: 2rem; margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: .94rem; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mini-select select { border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 8px 34px 8px 14px; min-height: 42px; }
.cap { color: var(--muted); font-size: .86rem; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: 0 1px 2px rgba(31,45,39,.04); }
.panel-title { font-family: "Lora", Georgia, serif; font-size: 1.3rem; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.panel-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.split-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr); gap: 24px; align-items: start; }
.preview-wrap { position: sticky; top: 132px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 22px; padding: 16px; max-height: calc(100vh - 150px); overflow: auto; }
.preview-label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 4px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.settings-grid > :first-child { grid-row: span 2; }

/* Forms */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span, .field-label { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .line input {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 12px; padding: 10px 12px; min-height: 44px;
  outline: none; width: 100%; min-width: 0; transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; line-height: 1.45; min-height: 64px; }
.field input:hover, .field select:hover, .field textarea:hover, .line input:hover { border-color: #9fb3a6; }
.field input:focus, .field select:focus, .field textarea:focus, .line input:focus { border-color: var(--pine-soft); box-shadow: var(--ring); }
.hours-out output { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--paper); border: 1px dashed var(--line-strong); font-family: "Lora", Georgia, serif; font-size: 1.25rem; }
.group { font-family: "Lora", Georgia, serif; font-weight: 600; font-size: 1.1rem; letter-spacing: -0.01em; margin: 10px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.hint { color: var(--muted); font-size: .86rem; margin: 0 0 12px; line-height: 1.5; }
.notice { background: rgba(242,193,46,.18); border: 1px solid rgba(214,160,20,.55); border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin: 0 0 14px; }
.incident-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.incident-box { border-left: 3px solid var(--copper); padding: 2px 0 2px 14px; margin-bottom: 8px; }
.notes { margin-top: 16px; }

.seg { display: inline-flex; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; gap: 2px; }
.seg .chip { border-color: transparent; background: transparent; }
.chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 7px 16px; font-size: 0.9rem; font-weight: 500; min-height: 38px; transition: background-color .15s ease, color .15s ease; }
.chip.on, .seg .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg .chip[data-incident="yes"].on { background: var(--copper); border-color: var(--copper); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.main-actions { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Invoice lines */
.inv-row { display: grid; grid-template-columns: 138px minmax(0, 1fr) minmax(0, 1.6fr) 78px 92px 40px; gap: 8px; align-items: center; }
.row-head { color: var(--muted); font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px; }
.line { margin-bottom: 8px; }
.line input { padding: 8px 10px; font-size: .92rem; }
.icon-btn { width: 40px; height: 40px; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.icon-btn:hover { background: rgba(154, 74, 42, 0.08); color: var(--copper); }

/* Lists */
.list { display: grid; gap: 10px; }
.row-card {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: center; width: 100%;
  border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px 18px; text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.row-card:hover { border-color: var(--line-strong); box-shadow: 0 8px 22px rgba(31,45,39,.06); transform: translateY(-1px); }
.row-card b { display: block; font-weight: 600; }
.row-card small { display: block; color: var(--muted); font-size: .86rem; margin-top: 2px; }
.row-card .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--pine); font-weight: 600; letter-spacing: .02em; }
#participantList .row-card { grid-template-columns: 44px minmax(0, 1fr) auto; }
.badge { display: inline-block; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 9px; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); background: #fff; white-space: nowrap; }
.badge.done { background: var(--pine); color: #ffffff; border-color: var(--pine); }
.badge.late { border-color: var(--copper); color: var(--copper); background: #fbf3ef; }
.empty {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  border: 1.5px dashed var(--line-strong); border-radius: 18px; padding: 24px 24px 24px 72px; position: relative;
  color: var(--muted); background: rgba(255,253,249,.6); margin: 0;
}
.empty::before {
  content: ""; position: absolute; left: 24px; top: 24px; width: 30px; height: 36px; border-radius: 5px; border: 2px solid var(--line-strong);
  background: linear-gradient(var(--line-strong),var(--line-strong)) 6px 10px / 14px 2px no-repeat, linear-gradient(var(--line-strong),var(--line-strong)) 6px 17px / 12px 2px no-repeat;
}
.empty::after { content: ""; position: absolute; left: 46px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--wattle); box-shadow: 7px 5px 0 -1px var(--wattle); }
.empty b { color: var(--ink); font-weight: 600; }
.empty-action { margin-top: 10px; }
.empty.small { padding: 18px 18px 18px 64px; }
.empty.small::before { left: 18px; top: 18px; }
.empty.small::after { left: 40px; top: 12px; }

.item-list { display: grid; gap: 8px; margin-top: 14px; }
.item-row { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px; }
.item-row:hover { border-color: var(--line-strong); }
.item-row .code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .82rem; color: var(--ink-2); overflow-wrap: anywhere; }
.item-row .desc { font-size: .92rem; }
.item-row .rate { font-weight: 600; white-space: nowrap; }
.item-row .rate small { color: var(--muted); font-weight: 400; }
.fineprint { color: var(--muted); font-size: .84rem; line-height: 1.55; margin: 14px 0 0; }

/* Hours */
.filters { margin-bottom: 16px; padding-bottom: 10px; }
.range-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.stat span { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat b { display: block; font-family: "Lora", Georgia, serif; font-weight: 600; font-size: 1.5rem; margin-top: 4px; letter-spacing: -.01em; }
.table-panel { padding: 8px 18px 14px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
caption { text-align: left; font-family: "Lora", Georgia, serif; font-size: 1.05rem; padding: 14px 0 6px; font-weight: 600; }
th { text-align: left; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: #5b6a63; padding: 6px 8px 8px 0; font-weight: 500; }
td { padding: 9px 8px 9px 0; border-top: 1px solid #e9eee8; vertical-align: top; }
tfoot td { font-weight: 600; border-top: 1px solid var(--ink); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.num + td:not(.num), th.num + th:not(.num) { padding-left: 18px; }
@media print { .doc table td, .doc table th { padding-right: 8px; } }
.nowrap { white-space: nowrap; }
td.code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .78rem; overflow-wrap: anywhere; }

/* Paper documents */
.paper { background: #fff; color: #1f2d27; border-radius: 10px; padding: 30px 28px; box-shadow: var(--shadow); min-height: 520px; }
.doc { font-size: .9rem; }
.paper-top { display: flex; justify-content: space-between; gap: 12px; }
.doc-kind { font-family: "Lora", Georgia, serif; font-size: 1.9rem; margin: 0 0 4px; letter-spacing: -0.02em; line-height: 1.1; }
.biz { margin-top: 8px; }
.biz strong, .bill strong { display: block; font-size: 1rem; }
.biz, .meta, .bill { font-size: 0.86rem; line-height: 1.5; color: #36463f; }
.meta { text-align: right; }
.rule { height: 1px; background: #e3e9e2; margin: 16px 0; }
.bill { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lbl { display: block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #5b6a63; margin-bottom: 2px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv span { display: block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: #5b6a63; }
.kv b { font-weight: 500; font-size: .9rem; overflow-wrap: anywhere; }
.note-sec { margin: 0 0 14px; break-inside: avoid; }
.note-sec h4 { margin: 0 0 3px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: #5b6a63; font-weight: 500; }
.note-sec p { margin: 0 0 4px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.note-sec.incident.yes { border-left: 3px solid #9a4a2a; padding-left: 10px; }
.note-sec.incident.yes > p:first-of-type { color: #9a4a2a; font-weight: 600; }
.signoff { margin-top: 18px; font-size: .8rem; color: #5b6a63; }
.doc .badge { margin-top: 2px; }
.due-note { color: #9a4a2a; font-size: 0.84rem; margin: 0 0 8px; }
.code-line { display: block; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .74rem; color: #56655e; letter-spacing: .01em; overflow-wrap: anywhere; }
.gf { font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: #5b6a63; white-space: nowrap; }
.totals { margin-left: auto; width: min(270px, 100%); margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 0.9rem; }
.totals .due { font-family: "Lora", Georgia, serif; font-size: 1.25rem; border-top: 1px solid #1f2d27; margin-top: 6px; padding-top: 8px; }
.paybox { margin-top: 16px; font-size: 0.84rem; color: #36463f; line-height: 1.5; }
.note { margin-top: 16px; font-size: 0.84rem; color: #56655e; }
.gst-note { margin: 8px 0 0; font-size: .78rem; color: #5b6a63; }
.watermark { margin-top: 24px; font-size: 0.72rem; color: #93a39a; letter-spacing: 0.08em; text-transform: uppercase; }
.print-area { display: none; }

/* Picker */
.pick-list { display: grid; gap: 8px; max-height: 42vh; overflow: auto; margin: 4px 0 6px; }
.pick { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.pick input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--pine); flex: none; }
.pick b { display: block; font-weight: 600; font-size: .94rem; }
.pick small { color: var(--muted); }

.privacy { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 8px 22px 36px; margin: 0; line-height: 1.6; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 8px); max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; font-size: 0.92rem; text-align: center;
  box-shadow: 0 10px 30px rgba(31,45,39,.25); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Sheets */
.paywall { position: fixed; inset: 0; background: rgba(31,45,39,.5); display: none; place-items: center; padding: 18px; z-index: 20; }
.paywall.open { display: grid; animation: fade .18s ease; }
.paywall.open .sheet { animation: rise .22s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.sheet { width: min(520px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; background: var(--paper); border-radius: 24px; padding: 26px; box-shadow: 0 30px 80px rgba(31,45,39,.3); margin: 0; }
.sheet.wide { width: min(640px, 100%); }
.sheet h3 { font-family: "Lora", Georgia, serif; margin: 0 0 8px; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.015em; }
.sheet p { color: var(--muted); line-height: 1.55; }
.price { font-family: "Lora", Georgia, serif; font-size: 2rem; margin: 8px 0; }
.buy-line { margin: 16px 0 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media screen and (max-width: 1000px) {
  .split-edit { grid-template-columns: 1fr; }
  .preview-wrap { position: static; max-height: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid > :first-child { grid-row: auto; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media screen and (max-width: 760px) {
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .app-header { padding: 10px 14px; position: static; }
  .brand p { display: none; }
  .header-actions .btn { padding: 8px 14px; font-size: .88rem; }
  .tabs {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 8;
    justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); border-bottom: 0; background: rgba(247,248,243,.97);
  }
  .tab { flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 12px; font-size: .72rem; min-width: 0; flex: 1 1 0; min-height: 52px; }
  .tab.on { background: transparent; color: var(--pine); }
  .tab.on svg { stroke-width: 2.2; }
  .main { padding: 16px 12px 24px; }
  .view-head h2 { font-size: 1.65rem; }
  .head-actions { width: 100%; }
  .head-actions .btn.primary { flex: 1 1 auto; }
  .panel { padding: 18px 16px; border-radius: 20px; }
  .preview-wrap { padding: 10px; border-radius: 18px; }
  .paper { padding: 22px 18px; min-height: 0; }
  .grid, .grid.three { grid-template-columns: 1fr 1fr; }
  .grid.three > :last-child { grid-column: 1 / -1; }
  .field.full, .grid > .field:has(select), .grid > .field:has(textarea) { grid-column: 1 / -1; }
  .row-card { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; }
  .row-card .when { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; }
  .row-card .when small { margin: 0; }
  #participantList .row-card .tags { grid-column: 1 / -1; justify-content: flex-start; }
  .row-head { display: none; }
  .inv-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .line { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .line [data-k=desc] { grid-column: 1 / -1; order: -1; }
  .line [data-k=date] { grid-column: 1 / 2; }
  .line [data-k=code] { grid-column: 2 / 4; }
  .main-actions .btn { flex: 1 1 calc(50% - 8px); }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .bill, .kv { grid-template-columns: 1fr; gap: 10px; }
  .paper-top { flex-direction: column; }
  .meta { text-align: left; }
  .doc table thead { display: none; }
  .doc table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 8px; padding: 10px 0; border-top: 1px solid #e9eee8; }
  .doc table td { border: 0; padding: 0; }
  .doc table td:nth-child(1) { grid-column: 1 / -1; font-size: .78rem; color: #5b6a63; }
  .doc table td:nth-child(2) { grid-column: 1 / -1; padding-bottom: 4px; }
  .doc table td.num { text-align: left; padding-left: 0; }
  .doc table td.num:last-child { text-align: right; font-weight: 600; }
  .item-row { grid-template-columns: minmax(0, 1fr) auto; }
  .item-row .desc { grid-column: 1 / 2; grid-row: 2; }
  .sheet { padding: 22px 18px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .privacy { padding-bottom: 24px; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #fff; padding: 0 !important; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .print-area, .print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc { font-size: 10.5pt; }
  .paper-top { flex-direction: row !important; }
  .meta { text-align: right !important; }
  .bill, .kv { grid-template-columns: 1fr 1fr !important; }
  tr, .totals, .paybox, .note-sec { break-inside: avoid; }
  .report-page { break-after: page; }
  .report-page:last-child { break-after: auto; }
}
.panel > .sub, .panel-title-row + .sub { margin-bottom: 14px; }

/* Illustrated empty states */
.empty.has-art { align-items:center; text-align:center; padding:20px; }
.empty.has-art::before, .empty.has-art::after { display:none; }
.empty.has-art .empty-art { width:min(200px,70%); height:auto; margin:0 auto 6px; display:block; }

/* ---------- Quick wins (wattle-notes-v9): Home, resume, templates, travel, incident, logo ---------- */
.home-h { font-family: "Outfit", system-ui, sans-serif; font-size: 1rem; margin: 20px 0 8px; color: var(--ink); }
.home-note { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; background: var(--sage); color: var(--pine-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin: 0 0 12px; }
.home-note .actions { margin: 0; }
.stats .stat small { display: block; color: var(--muted); font-size: .8rem; }
.stats .stat.late b { color: #9A3412; }
.shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.shortcuts .btn, .home-note .btn, .tpl-row .btn, .tpl-row select, .odo-row .btn, .tpl-list .btn, #travelPanel .btn, #printIncident { min-height: 44px; }
.tpl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.tpl-row .field { flex: 1 1 200px; margin: 0; }
.odo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.odo-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.logo-preview { max-width: 160px; max-height: 56px; object-fit: contain; }
.doc-logo { display: block; max-width: 200px; max-height: 64px; object-fit: contain; margin-bottom: 8px; }
.tpl-list { list-style: none; margin: 0; padding: 0; }
.tpl-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.tpl-list li:last-child { border: 0; }
.tpl-list li.none { color: var(--muted); }
.inc-table th { width: 34%; text-align: left; vertical-align: top; }
.odo-fig { margin: 16px 0 0; } .odo-fig img { max-width: 60%; border: 1px solid #ccc; } .odo-fig figcaption { font-size: .8rem; color: #444; }
#travelPanel { margin-top: 12px; }
@media (max-width: 700px) { .shortcuts { grid-template-columns: 1fr 1fr; } .tab { font-size: .66rem; } }
#pLogoFile, #sOdoPhoto { left: 0; top: 0; } .odo-row, #logoRow { position: relative; } .field:has(#pLogoFile), .field:has(#sOdoPhoto) { position: relative; }

/* Pro polish (wattle-notes-v9): keeps eucalyptus/wattle palette, Lora headings and existing art; 8px rhythm. */
.home-banner { margin: 0 0 16px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.home-banner img { display: block; width: 100%; height: auto; }
.home-h.eyebrow { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 24px 0 8px; }
#homeStats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#homeStats .stat { border-radius: 12px; padding: 12px; }
#homeStats .stat b, .stat b, table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; }
.badge { font-weight: 600; font-size: .74rem; }
.sheet { border-radius: 16px; }
@media (max-width: 700px) { #homeStats { grid-template-columns: 1fr 1fr; } }
#homeStats .stat { grid-column: auto !important; } #homeStats .stat b { font-size: 1.35rem; }

/* Keyboard open: hide the tab bar so it never covers a field, and keep focused fields clear of it. */
html { scroll-padding-top: 16px; scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
@media screen and (max-width: 760px) {
  /* Only the phone bottom bar hides; the desktop top bar stays put so nothing jumps under the pointer. */
  body:has(input:focus, textarea:focus, select:focus) .tabs { display: none !important; }
}
.odo-err { margin: 0; color: #a3261b; font-weight: 600; font-size: .9375rem; }
.odo-err[hidden] { display: none; }

/* Tap targets at least 44px (header, tabs, buttons). */
.app-header .brand, .app-header .btn, .mode-tabs .chip, .tabs .tab, .skip, .btn { min-height: 44px; }
.app-header .btn, .mode-tabs .chip { display: inline-flex; align-items: center; justify-content: center; }

/* ===== Wattle Notes' own look (wattle-notes-v12): the support worker's field notebook =====
   Fonts: Lora headings + Source Sans 3 body. Cream ruled paper, wattle-yellow as the action colour with dark
   eucalyptus ink, an ink index-tab bar, ruled tally on Home. Not shared with any other Muscat Labs app. */
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/source-sans-3-latin.woff2) format("woff2"); }
:root { font-family: "Source Sans 3", system-ui, sans-serif; --paper: #fffbec; --card: #fffef8; --line: #e9e0bf; --line-strong: #d8cc9c; }
html, body { background: var(--paper); }
.main { background-image: repeating-linear-gradient(180deg, transparent 0 31px, rgba(61,107,92,.07) 31px 32px); background-attachment: local; }
.app-header { background: var(--card); border-bottom: 6px solid var(--wattle); }
.brand h1 { color: var(--ink); }
.btn { border-radius: 10px; border-color: var(--line-strong); box-shadow: 0 2px 0 var(--line-strong); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--wattle); color: var(--ink); border-color: #c9960c; box-shadow: 0 2px 0 #c9960c; font-weight: 700; }
.btn.primary:hover { background: var(--wattle-2); border-color: #b5870b; }
.pro-btn { background: #fff3b8; color: var(--ink); border: 1px dashed #b5870b; border-radius: 3px; box-shadow: none; transform: rotate(-1.5deg); font-weight: 700; }
.pro-btn.is-pro { background: var(--wattle); color: var(--ink); border-style: solid; }
.tabs { background: var(--ink); border-bottom: 0; }
.tab { color: #f3efd9; border-radius: 6px 6px 0 0; }
.tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab.on { background: var(--wattle); color: var(--ink); box-shadow: none; font-weight: 700; }
@media (max-width: 760px) {
  .tabs { background: var(--ink); border-top: 3px solid var(--wattle); }
  .tab { color: #f3efd9; border-radius: 0 0 8px 8px; }
  .tab.on { background: var(--wattle); color: var(--ink); }
}
/* Home: a notebook page */
.wn-page-head { align-items: center; flex-wrap: nowrap; }
.wn-page-tag { margin: 0 0 2px; display: inline-block; background: var(--wattle); color: var(--ink); font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 2px; }
.home-banner.wn-snap { flex: none; width: 150px; margin: 0; border-radius: 4px; border: 6px solid #fff; box-shadow: 0 6px 16px -8px rgba(31,45,39,.45); transform: rotate(2.5deg); position: relative; }
.home-banner.wn-snap::before { content: ""; position: absolute; top: -10px; left: 50%; width: 54px; height: 18px; margin-left: -27px; background: rgba(242,193,46,.75); transform: rotate(-4deg); }
@media (max-width: 520px) { .home-banner.wn-snap { width: 104px; border-width: 4px; } }
.home-h.eyebrow { font-family: "Lora", Georgia, serif; text-transform: none; letter-spacing: 0; font-size: 1.05rem; font-style: italic; color: var(--ink-2); }
#homeStats { gap: 0; background: var(--card); border: 1px solid var(--line-strong); border-radius: 4px; }
#homeStats .stat { background: none; border: 0; border-radius: 0; border-left: 1px solid var(--line-strong); padding: 12px 14px; }
#homeStats .stat:first-child { border-left: 0; }
#homeStats .stat span { color: var(--ink-2); font-weight: 600; }
@media (max-width: 700px) {
  #homeStats .stat:nth-child(3) { border-left: 0; }
  #homeStats .stat:nth-child(n+3) { border-top: 1px solid var(--line-strong); }
}
.shortcuts { grid-template-columns: 1fr; gap: 0; background: var(--card); border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.shortcuts .btn { justify-content: space-between; border: 0; border-radius: 0; box-shadow: none; border-left: 6px solid transparent; min-height: 52px; padding: 10px 16px; background: none; font-size: 1rem; }
.shortcuts .btn + .btn { border-top: 1px solid var(--line); }
.shortcuts .btn::after { content: "›"; font-size: 1.4rem; color: var(--ink-2); }
.shortcuts .btn.primary { background: #fff3b8; border-left-color: var(--wattle-2); box-shadow: none; }
@media (max-width: 700px) { .shortcuts { grid-template-columns: 1fr; } }
.home-note { border-radius: 4px; background: #fff3b8; border: 1px solid #e6cf75; color: var(--ink); }
.row-card { border-radius: 4px; }
.tabs .tab { transition: none; } /* no mid-fade colours: the active tab is always full contrast */
