:root {
  --bg: #FBF3EC;
  --card: #FFF8F0;
  --primary: #A8573F;
  --primary-dark: #8A4833;
  --secondary: #7C8B6F;
  --text: #3B2E28;
  --muted: #8A766B;
  --border: #F0E2D2;
  --chip: #E9D9C8;
  --chip-text: #6B4631;
  --positive: #7C8B6F;
  --negative: #A8573F;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-head: 'Lora', serif;
  --font-body: 'Nunito Sans', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior-y: none;
  height: 100%;
}

body { position: relative; width: 100%; max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 86px; }

button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }

.hidden { display: none !important; }

.statusbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 22px 0; font-size: 13px; font-weight: 700; opacity: 0.001; height: 0; overflow: hidden; }

.screen { padding: 14px 20px 10px; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.page-title { font-family: var(--font-head); font-size: 23px; font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 1px 3px rgba(59,46,40,0.08); transition: transform .15s ease; }
.icon-btn:active { transform: scale(0.9); }

.greet { font-family: var(--font-head); font-size: 23px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.encourage { margin-top: 6px; font-size: 13.5px; color: var(--muted); line-height: 1.4; min-height: 18px; }

.weekstrip { display: flex; justify-content: space-between; margin-top: 16px; background: var(--card); border-radius: var(--radius-md); padding: 10px 8px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }
.weekday { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); font-weight: 700; flex: 1; }
.weekday .wnum { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text); }
.weekday.today .wnum { background: var(--primary); color: #fff; }
.weekday .wdot { width: 4px; height: 4px; border-radius: 50%; background: var(--secondary); margin-top: 1px; }
.weekday .wdot.empty { background: transparent; }

.section-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; margin: 16px 0 7px 2px; }

.card { background: var(--card); border-radius: var(--radius-lg); padding: 14px 16px; position: relative; padding-left: 20px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); transition: transform .15s ease; }
.card:active { transform: scale(0.985); }
.card::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 3px; background: var(--primary); }
.card.accent-secondary::before { background: var(--secondary); }
.card-title { font-weight: 700; font-size: 15px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.card.empty { text-align: center; color: var(--muted); font-size: 13px; padding-left: 16px; }
.card.empty::before { display: none; }

.row2 { display: flex; gap: 10px; margin-top: 14px; }
.row3 { display: flex; gap: 9px; }
.stat { flex: 1; background: var(--card); border-radius: var(--radius-md); padding: 13px 14px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }
.stat .lbl { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat .amt { font-weight: 800; font-size: 20px; margin-top: 4px; }
.stat .amt.good { color: var(--positive); }
.stat .amt.bad { color: var(--negative); }
.stat .sub2 { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

.chips { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip { background: var(--chip); color: var(--chip-text); font-size: 11.5px; font-weight: 700; padding: 6px 11px; border-radius: 20px; }

.hero { background: var(--primary); border-radius: var(--radius-lg); padding: 18px 20px; color: #FBF3EC; }
.hero .lbl { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(251,243,236,0.75); }
.hero .amt { font-weight: 800; font-size: 32px; margin-top: 4px; }
.hero .sub { font-size: 12px; color: rgba(251,243,236,0.8); margin-top: 2px; }
.hero .delta { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 20px; }
.hero .delta.down { background: rgba(0,0,0,0.15); }
.bar { margin-top: 12px; height: 8px; border-radius: 6px; background: rgba(255,255,255,0.18); overflow: hidden; display: flex; }
.bar .earn { background: #F0D9C3; }
.bar .exp { background: rgba(255,255,255,0.35); }

.monthsel { display: flex; align-items: center; gap: 9px; background: var(--card); border-radius: 20px; padding: 6px 12px; font-size: 12.5px; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.monthsel button { color: var(--secondary); font-weight: 800; font-size: 15px; padding: 0 2px; }

.txlist, .listbox { background: var(--card); border-radius: var(--radius-md); padding: 3px 14px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }
.tx { display: flex; align-items: center; gap: 11px; padding: 10px 0; }
.tx:not(:last-child) { border-bottom: 1px solid var(--border); }
.txicon { width: 34px; height: 34px; border-radius: 10px; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.txbody { flex: 1; min-width: 0; }
.txname { font-size: 13.5px; font-weight: 700; }
.txsub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.txamt { font-weight: 800; font-size: 14px; white-space: nowrap; }
.txamt.pos { color: var(--positive); }
.txamt.neg { color: var(--negative); }

.joblist-item { position: relative; overflow: hidden; border-radius: var(--radius-md); margin-bottom: 10px; }
.joblist-item .swipebg { position: absolute; inset: 0; background: var(--secondary); display: flex; align-items: center; padding: 0 20px; color: #fff; font-weight: 700; font-size: 14px; }
.joblist-item .swipefg { position: relative; background: var(--card); border-radius: var(--radius-md); padding: 13px 16px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); display: flex; align-items: center; gap: 12px; touch-action: pan-y; }
.joblist-item.done .swipefg { opacity: 0.55; }
.joblist-item.done .jtitle { text-decoration: line-through; }
.jstatusdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.jstatusdot.enquiry { background: #D7B36A; }
.jstatusdot.booked { background: var(--secondary); }
.jstatusdot.done { background: var(--primary); }
.jstatusdot.cancelled { background: #B7ADA2; }
.jinfo { flex: 1; min-width: 0; }
.jtitle { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jsub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.jprice { font-weight: 800; font-size: 14px; }
.badge-overdue { position: absolute; top: -6px; right: 10px; background: #A8573F; color: #fff; font-size: 9.5px; font-weight: 800; padding: 3px 8px; border-radius: 10px; box-shadow: 0 2px 6px rgba(168,87,63,0.4); }

.filterbar { display: flex; gap: 7px; margin: 10px 0 14px; overflow-x: auto; }
.filterchip { padding: 7px 13px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--card); color: var(--muted); white-space: nowrap; }
.filterchip.active { background: var(--primary); color: #fff; }

.fab-wrap { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; z-index: 40; }
.addbtn { margin: 0 20px 10px; background: var(--secondary); color: #FFF8F0; border-radius: 22px; height: 54px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; box-shadow: 0 8px 18px rgba(124,139,111,0.4); transition: transform .12s ease; }
.addbtn:active { transform: scale(0.97); }
.addbtn .plus { font-size: 20px; margin-right: 7px; font-weight: 700; }

.nav { background: var(--card); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-around; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); }
.navitem { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: #B3A194; font-weight: 700; }
.navitem .nicon { font-size: 18px; }
.navitem.active { color: var(--primary); }

.sheet-overlay { position: fixed; inset: 0; background: rgba(59,46,40,0.42); z-index: 60; display: flex; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet { width: 100%; max-width: 480px; margin: 0 auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 20px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,0.15); transform: translateY(100%); transition: transform .32s cubic-bezier(.32,.72,0,1); max-height: 86vh; overflow-y: auto; }
.sheet-overlay.open .sheet { transform: translateY(0); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #DAD5C9; margin: 0 auto 14px; }
.sheet-title { font-family: var(--font-head); font-size: 19px; font-weight: 600; margin-bottom: 14px; }

.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.opt { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--card); border-radius: var(--radius-lg); padding: 14px 6px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); transition: transform .12s ease; }
.opt:active { transform: scale(0.95); }
.opticon { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.opt .lbl { font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.2; }
.invoicefull { grid-column: span 3; flex-direction: row; justify-content: center; gap: 10px; background: var(--primary); }
.invoicefull .lbl { color: #fff; font-weight: 700; font-size: 14px; }
.invoicefull .opticon { background: rgba(255,255,255,0.22); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.field-input-wrap { position: relative; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 14px; font-size: 14.5px; font-weight: 600; color: var(--text);
}
.field input[type="text"], .field input[type="number"] { padding-right: 46px; }
.field textarea { min-height: 76px; resize: vertical; font-weight: 500; padding-right: 46px; }
.mic-btn { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border-radius: 50%; background: var(--secondary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.mic-btn.listening { background: var(--primary); animation: pulseMic 1s infinite; }
@keyframes pulseMic { 0%{ box-shadow: 0 0 0 0 rgba(168,87,63,0.5); } 70%{ box-shadow: 0 0 0 10px rgba(168,87,63,0); } 100%{ box-shadow: 0 0 0 0 rgba(168,87,63,0); } }
.statuspicker { display: flex; gap: 7px; }
.statuspicker button { flex: 1; padding: 10px 4px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); font-size: 11.5px; font-weight: 700; color: var(--muted); }
.statuspicker button.sel { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-primary { width: 100%; background: var(--primary); color: #fff; border-radius: 16px; height: 50px; font-weight: 800; font-size: 15.5px; margin-top: 6px; transition: transform .12s ease; }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 16px; height: 46px; font-weight: 700; font-size: 14px; margin-top: 8px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .trow-label { font-weight: 700; font-size: 13.5px; }
.toggle-row .trow-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.switch { width: 46px; height: 27px; border-radius: 20px; background: #DCD2C4; position: relative; flex-shrink: 0; transition: background .2s ease; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%; background: #fff; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch.on { background: var(--secondary); }
.switch.on .knob { transform: translateX(19px); }

.swatches { display: flex; gap: 10px; margin-top: 4px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch.sel { border-color: var(--text); }

/* Job detail */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.pill { font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; background: var(--chip); color: var(--chip-text); padding: 6px 13px; border-radius: 20px; }
.headblock { margin-top: 10px; }
.jd-title { font-family: var(--font-head); font-size: 22px; font-weight: 600; }
.jd-subtitle { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.meta { display: flex; gap: 16px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.meta span b { color: var(--text); font-weight: 700; }

.pricebox { margin-top: 14px; background: var(--card); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }
.pricecell { flex: 1; text-align: center; }
.pricecell + .pricecell { border-left: 1px solid var(--border); }
.pricecell .lbl { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pricecell .val { font-weight: 800; font-size: 16px; margin-top: 4px; }
.pricecell .val.due { color: var(--negative); }
.pricecell .val.paid { color: var(--positive); }

.quickrow { display: flex; justify-content: space-between; margin-top: 16px; }
.qbtn { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; color: var(--muted); }
.qicon { width: 44px; height: 44px; border-radius: 14px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 17px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }

.todolist { background: var(--card); border-radius: var(--radius-md); padding: 5px 14px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); }
.todo { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 13.5px; }
.todo:not(:last-child) { border-bottom: 1px solid var(--border); }
.check { width: 19px; height: 19px; border-radius: 6px; border: 2px solid var(--secondary); flex-shrink: 0; position: relative; transition: background .15s ease; }
.check.done { background: var(--secondary); border-color: var(--secondary); }
.check.done::after { content: "✓"; position: absolute; inset: 0; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.todo.done span { color: #B3A194; text-decoration: line-through; }
.todo span { flex: 1; }
.flash { animation: flashGreen .5s ease; }
@keyframes flashGreen { 0% { background: rgba(124,139,111,0.35); } 100% { background: transparent; } }

.photorow { display: flex; gap: 9px; margin-top: 4px; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; border-radius: 12px; background-size: cover; background-position: center; background-color: var(--chip); }
.thumb.add { background: var(--card); border: 1.5px dashed var(--secondary); display: flex; align-items: center; justify-content: center; color: var(--secondary); font-size: 20px; font-weight: 700; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; background: var(--card); border-top: 1px solid var(--border); padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); z-index: 30; }
.invoicebtn { background: var(--primary); color: #fff; border-radius: 16px; height: 50px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15.5px; }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.cal-dow { text-align: center; font-size: 10px; font-weight: 800; color: var(--muted); padding-bottom: 4px; }
.cal-cell { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; position: relative; background: var(--card); }
.cal-cell.other { opacity: 0.25; }
.cal-cell.today { outline: 2px solid var(--primary); }
.cal-cell .cdot { display: flex; gap: 2px; margin-top: 3px; }
.cal-cell .cdot span { width: 4px; height: 4px; border-radius: 50%; background: var(--secondary); }
.cal-cell .cdot span.meet { background: var(--primary); }
.cal-daylist { margin-top: 16px; }

/* Invoice */
.invoice-doc { background: #fff; border-radius: var(--radius-lg); padding: 18px; box-shadow: 0 1px 2px rgba(59,46,40,0.05), 0 5px 16px rgba(59,46,40,0.06); font-size: 13px; }
.invoice-doc textarea { width: 100%; min-height: 420px; border: none; font-family: var(--font-body); font-size: 13.5px; line-height: 1.6; color: var(--text); background: transparent; }
.invoice-doc textarea:focus { outline: none; }
.invoice-actions { display: flex; gap: 10px; margin-top: 14px; }
.invoice-actions button { flex: 1; }

.encourage-icon { font-size: 19px; }

@media print {
  body * { visibility: hidden; }
  #printable, #printable * { visibility: visible; }
  #printable { position: absolute; left: 0; top: 0; width: 100%; padding: 20px; }
}

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13px; font-weight: 600; z-index: 100; opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.countup { display: inline-block; }
