/* Mongoose Business. The look follows the agreed mockup (docs/MONGOOSE_BUSINESS_PLAN.md section 6): warm paper, one orange
   accent for actions, green for "done", plain words, 44px touch targets. Phone first; a sidebar from 960px. */
:root {
  --bg: #faf8f5; --card: #fff; --text: #241f1b; --muted: #625b56; --soft: #4a433e; --line: #e7ded6; --line-soft: #f0e9e2;
  --sand: #f4efe9; --accent: #bf4a12; --accent-ink: #a8410f; --accent-soft: #fdf6f1; --good: #22675c; --good-soft: #e3f1ea;
  --warn: #8a5a00; --warn-soft: #fbf1dc; --bad: #a3271b; --bad-soft: #fbe9e6; --blue: #1f4f8a; --blue-soft: #e6eef9;
  --radius: 16px; --tab: 68px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent-ink); }
a:hover { color: #7d300b; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f0a97c; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- Buttons ---- */
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #e0d6cc; background: #fff; color: var(--text); font-weight: 600; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--sand); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #a63f0f; color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0c9c3; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.fit { align-self: flex-start; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent-ink); font-weight: 600; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 22px; border: 1px solid #e0d6cc; background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: var(--sand); border-radius: 10px; padding: 3px; }
.seg button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; font-weight: 700; box-shadow: 0 1px 2px rgba(36,31,27,.12); }

/* ---- Layout ---- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid #ece4dc; }
.top .biz { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; min-width: 0; }
.top .biz span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .mark { width: 40px; height: 40px; border-radius: 10px; image-rendering: pixelated; display: block; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px calc(var(--tab) + 28px); display: flex; flex-direction: column; gap: 22px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: var(--tab); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--accent-ink); font-weight: 700; }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.side { display: none; }
.side .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; line-height: 22px; text-align: center; }
@media (min-width: 960px) {
  .shell { flex-direction: row; }
  .top { display: none; }
  .tabs { display: none; }
  .side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; width: 240px; flex-shrink: 0; padding: 18px 12px; background: var(--sand); border-right: 1px solid var(--line); overflow-y: auto; }
  .side .who { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
  .side .who img { width: 40px; height: 40px; border-radius: 10px; image-rendering: pixelated; }
  .side .who b { display: block; font-size: 17px; }
  .side .who small { color: var(--muted); font-size: 13px; }
  .side a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border-radius: 10px; color: #3b3430; text-decoration: none; font-weight: 600; font-size: 15px; }
  .side a[aria-current="page"] { background: #fff; color: var(--accent-ink); font-weight: 700; box-shadow: 0 1px 2px rgba(36,31,27,.08); }
  .side .grow { flex: 1; }
  .main { max-width: 1040px; padding: 32px 36px 48px; }
}

/* ---- Content ---- */
.lead { display: flex; flex-direction: column; gap: 4px; }
.lead .date { font-size: 14px; color: var(--muted); }
.lead p { font-size: 16px; color: var(--soft); }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tight { padding: 4px 16px; gap: 0; }
.card.warn { border-color: #efd29a; }
.card.bad { border-color: #ecb7ae; }
a.card { color: var(--text); text-decoration: none; }
a.card:hover { border-color: #d9cdc1; }
.card .title { font-weight: 700; font-size: 16px; }
.card .sub { font-size: 15px; color: var(--soft); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.fine { font-size: 14px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--sand); color: var(--soft); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: #1d6b4f; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--sand); color: var(--soft); }
.icon.blue { background: var(--blue-soft); color: var(--blue); }
.icon.good { background: var(--good-soft); color: var(--good); }
.icon.warn { background: var(--warn-soft); color: var(--warn); }
.icon.bad { background: var(--bad-soft); color: var(--bad); }
.item { display: flex; gap: 12px; align-items: flex-start; }
.item > div:not(.icon) { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .n { font-size: 22px; font-weight: 800; }
.tile .l { font-size: 13px; color: var(--muted); }
.progress { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.progress > i { display: block; height: 6px; background: var(--good); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 2px dashed #e3d8cc; border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.draft { background: var(--sand); border-radius: 12px 12px 12px 4px; padding: 10px 12px; font-size: 15px; white-space: pre-wrap; }
.bubble { background: var(--sand); border-radius: 12px 12px 12px 4px; padding: 10px 12px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.search { width: 100%; min-height: 44px; border: 1px solid #e0d6cc; border-radius: 10px; padding: 0 14px; background: #fff; }

/* Stages */
.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stages li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.stages .dot { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; border: 2px solid #d9cdc1; background: #fff; margin-top: 1px; display: flex; align-items: center; justify-content: center; }
.stages li.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.stages li.now .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px #f7dccb; }
.stages li.now b { color: var(--accent-ink); }
.stages small { display: block; color: var(--muted); font-size: 13px; }
.stages button { margin-left: auto; }

/* Schedule */
.week { display: flex; flex-direction: column; gap: 10px; }
.day { display: flex; gap: 12px; }
.day .when { width: 52px; flex-shrink: 0; text-align: center; padding-top: 10px; }
.day .when b { display: block; font-size: 20px; }
.day .when small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.day.today .when b { color: var(--accent-ink); }
.day .list { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.day .free { padding: 12px 0; color: #9a918a; font-size: 14px; border-top: 1px dashed var(--line); }
.slot { text-align: left; width: 100%; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.slot.k-inspection { border-left-color: #1f4f8a; }
.slot.k-adjuster { border-left-color: #7a3fb0; }
.slot.k-delivery { border-left-color: #8a5a00; }
.slot.k-walkthrough, .slot.k-care { border-left-color: var(--good); }
.slot.done { opacity: .55; text-decoration: line-through; }
.slot small { color: var(--muted); }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month .h { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.month button { min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 6px 2px; cursor: pointer; font-weight: 600; }
.month button.out { opacity: .4; }
.month button.today { border-color: var(--accent); color: var(--accent-ink); }
.month .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.month .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { padding: 10px 0; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.timeline li:first-child { border-top: 0; }
.timeline small { color: var(--muted); font-size: 13px; }

/* Forms and dialogs */
form.stack, .stack { display: flex; flex-direction: column; gap: 14px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
label.f small { font-weight: 400; color: var(--muted); }
label.f input, label.f select, label.f textarea { min-height: 44px; border: 1px solid #d9cdc1; border-radius: 10px; padding: 8px 12px; background: #fff; font-weight: 400; width: 100%; }
label.f textarea { min-height: 96px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 600; }
label.check input { width: 22px; height: 22px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.error { color: var(--bad); font-weight: 600; font-size: 15px; min-height: 0; }
.error:empty { display: none; }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--bg); color: var(--text); box-shadow: 0 24px 60px rgba(36,31,27,.28); }
dialog::backdrop { background: rgba(36,31,27,.45); }
dialog .dlg { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab) + 16px); transform: translate(-50%, 20px); opacity: 0; background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px); }
.toast.shown { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: 24px; } }

/* Signed out */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.auth .brand { display: flex; align-items: center; gap: 12px; }
.auth .brand img { width: 48px; height: 48px; border-radius: 12px; image-rendering: pixelated; }
.auth .brand b { font-size: 20px; }
.auth .legal-links { display: flex; gap: 14px; justify-content: center; font-size: 14px; }
.or { text-align: center; color: var(--muted); font-size: 14px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
