:root {
  --primary: #1b5e3a; --primary-dark: #124128; --accent: #d23a2f; --accent-dark: #b02d24; --lime: #72bf4c;
  --bg: #f3f6f2; --card: #fff; --ink: #1b2420; --muted: #5a6560; --line: #dfe5de; --soft: #e8f0ea;
  --blue: #2b6cb0; --amber: #b7791f; --radius: 12px;
  --display: "Oswald", "Arial Narrow", sans-serif; --sans: "Inter", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.15; letter-spacing: .01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.no-scroll { overflow: hidden; }
.center { text-align: center; }

/* shell */
.demo-bar { background: #1b1d22; color: #e8ebf2; font-size: .82rem; text-align: center; padding: 6px 12px; }
.demo-bar button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font-weight: 700; padding: 0 4px; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 31px); }
.side { background: var(--primary-dark); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: calc(100vh - 31px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 46px; height: 46px; border-radius: 8px; background: #fff; object-fit: contain; }
.brand b { font-family: var(--display); font-size: 1.1rem; line-height: 1.1; display: block; text-transform: uppercase; }
.brand span { font-size: .72rem; opacity: .75; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: #cfe3d6; padding: 11px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-btn[aria-current="page"] { background: #fff; color: var(--primary-dark); }
.nav-btn svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn .count { margin-left: auto; background: var(--accent); color: #fff; font-size: .72rem; border-radius: 999px; padding: 1px 8px; font-weight: 700; }
.side .spacer { flex: 1; }
.side-foot { font-size: .78rem; opacity: .75; padding: 8px 10px; line-height: 1.5; }
.main { padding: 22px 28px 70px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.9rem; color: var(--primary-dark); text-transform: uppercase; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* controls */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.green { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: #fff; border-color: #e8b4b0; color: var(--accent-dark); }
.btn.sm { padding: 4px 10px; font-size: .86rem; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--soft); }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
textarea { resize: vertical; min-height: 84px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: .86rem; }
.field small { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px; cursor: pointer; font-weight: 600; font-size: .88rem; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.search { max-width: 220px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { font-size: 1.1rem; text-transform: uppercase; color: var(--primary-dark); margin-bottom: 10px; }
.card h3 small { font-family: var(--sans); text-transform: none; font-weight: 600; color: var(--muted); margin-left: 6px; font-size: .8rem; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--primary-dark); white-space: nowrap; }
.badge.red { background: #fbe4e1; color: var(--accent-dark); }
.badge.amber { background: #fdf0d6; color: #8a5a0b; }
.badge.blue { background: #e1ecf8; color: #1f4f85; }
.badge.gray { background: #eceeed; color: #555; }
.badge.green { background: #d9f0df; color: #14572f; }
.svc { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; color: var(--c); }
.svc::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.kpi b { display: block; font-family: var(--display); font-size: 2rem; color: var(--primary-dark); line-height: 1.15; margin-top: 2px; }
.kpi small { color: var(--muted); }
.kpi.alert { border-color: #f0b8b3; background: #fff6f5; }
.kpi.alert b { color: var(--accent-dark); }

/* lead board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.col { background: #e9efe8; border-radius: var(--radius); padding: 10px; min-height: 160px; }
.col.drop { outline: 2px dashed var(--primary); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 8px; }
.col-head h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }
.col-head small { color: var(--muted); font-weight: 600; }
.lead { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line)); border-radius: 10px; padding: 10px 12px; margin-bottom: 9px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.lead:hover { border-color: var(--primary); }
.lead[draggable="true"] { cursor: grab; }
.lead .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.lead b { font-size: .98rem; }
.lead .meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.lead .msg { font-size: .85rem; color: #39433e; margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead .foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.wait { font-weight: 700; color: var(--accent-dark); }
.fresh { background: var(--accent); color: #fff; border-radius: 5px; font-size: .66rem; padding: 1px 6px; text-transform: uppercase; font-weight: 800; margin-left: 6px; }
.lost-wrap { margin-top: 16px; }
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: .88rem; }
.bar-track { background: var(--soft); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bar-row b { text-align: right; }
.season { background: linear-gradient(100deg, #fbe4e1, #fff 60%); border: 1px solid #f0b8b3; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.season b { font-family: var(--display); font-size: 1.15rem; color: var(--accent-dark); text-transform: uppercase; }
.season span { color: #5b3a37; flex: 1; min-width: 220px; }

/* drawer + modal */
.drawer-wrap { position: fixed; inset: 0; background: rgba(15,25,20,.45); z-index: 80; display: flex; justify-content: flex-end; }
.drawer { width: min(520px, 100%); background: #fff; height: 100%; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.2); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer header, .modal header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.drawer header h2, .modal header h2 { font-size: 1.4rem; color: var(--primary-dark); text-transform: uppercase; }
.drawer-body { padding: 18px 22px 40px; }
.drawer-body section { margin-bottom: 20px; }
.drawer-body h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.overlay { position: fixed; inset: 0; background: rgba(15,25,20,.55); z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.wide { width: min(1080px, 100%); }
.modal-body { padding: 18px 22px 22px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.msg-box { background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: .93rem; white-space: pre-wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline small { display: block; color: var(--muted); }
.stage-steps { display: flex; gap: 4px; margin-bottom: 14px; }
.stage-steps button { flex: 1; border: 1px solid var(--line); background: #fff; padding: 7px 4px; font-size: .78rem; font-weight: 700; cursor: pointer; border-radius: 7px; }
.stage-steps button[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.stage-steps button.lost[aria-pressed="true"] { background: #6b7280; border-color: #6b7280; }
.templates { display: grid; gap: 6px; }
.templates button { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: .88rem; }
.templates button:hover { border-color: var(--primary); }

/* schedule */
.sched { display: grid; grid-template-columns: 1fr 250px; gap: 14px; align-items: start; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.job .jt { line-height: 1.25; }
.day { background: #fff; border: 1px solid var(--line); border-radius: 11px; min-height: 360px; display: flex; flex-direction: column; }
.day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--soft); }
.day.drop { outline: 2px dashed var(--primary); }
.day-head { padding: 8px 8px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.day-head b { font-family: var(--display); text-transform: uppercase; }
.day-head small { color: var(--muted); font-weight: 600; font-size: .75rem; }
.day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.job { border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 9%, #fff); border-radius: 7px; padding: 6px 8px; font-size: .8rem; cursor: pointer; }
.job:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.job b { display: block; font-size: .82rem; line-height: 1.25; }
.job .t { color: var(--muted); font-weight: 600; }
.job.done { opacity: .62; }
.job.done b { text-decoration: line-through; }
.job .st { font-size: .66rem; text-transform: uppercase; font-weight: 800; letter-spacing: .06em; color: var(--c); }
.add-slot { margin-top: auto; border: 1px dashed var(--line); background: none; border-radius: 7px; padding: 5px; color: var(--muted); cursor: pointer; font-size: .8rem; }
.add-slot:hover { color: var(--primary); border-color: var(--primary); }
.unsched .job { margin-bottom: 7px; }
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav h2 { font-size: 1.15rem; min-width: 190px; text-align: center; text-transform: uppercase; }

/* tables */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafcf9; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid #edf1ec; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #f7faf6; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabs { display: inline-flex; background: #e4ebe3; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.note { background: #fff9e8; border: 1px solid #f0dfa6; border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px; }
.note.info { background: var(--soft); border-color: #c9dccd; }
.url { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); word-break: break-all; }
.price-edit input { width: 90px; }

/* invoice builder + document */
.builder { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.items th { font-size: .72rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: 4px 4px; }
.items td { padding: 3px 3px; vertical-align: top; }
.items input { padding: 6px 8px; }
.items .q { width: 60px; } .items .r { width: 90px; }
.doc { border: 1px solid var(--line); border-radius: 10px; padding: 28px 30px; background: #fff; font-size: .9rem; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--primary); padding-bottom: 14px; margin-bottom: 16px; }
.doc-head img { width: 70px; height: 70px; object-fit: contain; }
.doc-head h3 { font-size: 1.5rem; color: var(--primary-dark); text-transform: uppercase; }
.doc-head .r { text-align: right; }
.doc-head .r b { font-family: var(--display); font-size: 1.7rem; color: var(--accent); text-transform: uppercase; display: block; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.doc th { text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
.doc td { padding: 7px 4px; border-bottom: 1px solid #eef2ed; }
.doc .n { text-align: right; white-space: nowrap; }
.doc .total { display: flex; justify-content: flex-end; gap: 24px; font-size: 1.15rem; font-weight: 700; margin-top: 8px; }
.doc .total b { font-family: var(--display); font-size: 1.5rem; color: var(--primary-dark); }
.paybtn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; padding: 11px 22px; border-radius: 9px; margin-top: 14px; }
.email-prev { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.email-prev .hd { background: var(--bg); padding: 10px 14px; font-size: .86rem; border-bottom: 1px solid var(--line); }
.email-prev .bd { padding: 16px 18px; }
.stripe-pill { display: inline-flex; align-items: center; gap: 6px; background: #635bff; color: #fff; border-radius: 999px; padding: 3px 11px; font-size: .75rem; font-weight: 700; }

/* toasts */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 120; align-items: center; }
.toast { background: #1b1d22; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); transition: opacity .3s; max-width: 90vw; }
.toast.out { opacity: 0; }
.toast.warn { background: var(--accent-dark); }

/* printing a document */
@media print {
  body > *:not(#print-doc) { display: none !important; }
  #print-doc { display: block !important; }
  .doc { border: 0; padding: 0; }
}
#print-doc { display: none; }

@media (max-width: 1500px) { .sched { grid-template-columns: 1fr; } .unsched { order: -1; } .unsched .job { display: inline-block; vertical-align: top; width: 260px; margin-right: 8px; } }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } .week { grid-template-columns: repeat(7, 150px); overflow-x: auto; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 4px; z-index: 70; justify-content: space-around; }
  .brand, .side .spacer, .side-foot { display: none; }
  #nav { display: contents; }
  .nav-btn { flex: 1; width: auto; }
  .nav-btn { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; text-align: center; justify-content: center; position: relative; }
  .nav-btn .count { position: absolute; top: 0; right: 6px; margin: 0; }
  .main { padding: 16px 14px 90px; }
  .page-head h1 { font-size: 1.5rem; }
  .two, .grid2, .grid3 { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(4, 260px); }
  .doc { padding: 18px 14px; }
}

/* sign-in (demo) */
.login { position: fixed; inset: 0; z-index: 200; background: linear-gradient(160deg, var(--primary-dark), var(--primary)); display: grid; place-items: center; padding: 16px; }
.login[hidden] { display: none; }
.login-card { background: #fff; border-radius: 16px; padding: 28px 28px 22px; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; }
.login-card .field { text-align: left; }
.login-logo { width: 110px; height: 110px; object-fit: contain; margin-bottom: 6px; }
.login-card h1 { font-size: 1.6rem; color: var(--primary-dark); text-transform: uppercase; }
.login-card p.muted { margin: 2px 0 18px; }
.demo-note { font-size: .82rem; color: var(--muted); margin: 14px 0 6px; }
.login .back { font-size: .9rem; }
/* Example's automatic sign-in: a card that rises in, a field that "types", a button that presses, then a fade into the dashboard */
.login-card { animation: login-rise .5s ease-out both; }
@keyframes login-rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.login-card input.typing { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.login-card button.pressed { transform: scale(.97); filter: brightness(.92); }
.login-card button.signing { pointer-events: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.login-card .spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: login-spin .7s linear infinite; }
@keyframes login-spin { to { transform: rotate(360deg); } }
.login.leaving { animation: login-out .45s ease-in forwards; }
.login.leaving .login-card { animation: login-card-out .45s ease-in forwards; }
@keyframes login-out { to { opacity: 0; } }
@keyframes login-card-out { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@media (prefers-reduced-motion: reduce) {
  .login-card { animation: none; }
  .login.leaving .login-card { animation: none; }
  .login-card button.pressed { transform: none; }
  .login-card .spin { animation-duration: 1.6s; }
}
