/* HOF & MOR CRM — warm paper palette taken from the logo */
:root {
  --paper: #f4f2ec;
  --card: #fffdf8;
  --ink: #4a3426;
  --ink-soft: #7d6655;
  --line: #e4dccd;
  --accent: #8a5a3b;
  --accent-ink: #fffdf8;
  --sand: #efe7d8;
  --ok: #4f7a4a;
  --warn: #b07a1e;
  --danger: #a3473b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(74, 52, 38, .06), 0 4px 14px rgba(74, 52, 38, .05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 "Segoe UI", "Assistant", "Rubik", Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 900px) { body { padding-bottom: 24px; } }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; font-weight: 700; }
h2 { font-size: 1.08rem; margin: 0 0 .7rem; font-weight: 700; }
h3 { font-size: .98rem; margin: 0 0 .5rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ── header ── */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(244, 242, 236, .94);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.brand span { font-weight: 700; letter-spacing: .04em; }
.mainnav { display: none; gap: 2px; }
.mainnav a { padding: 7px 11px; border-radius: 9px; color: var(--ink-soft); font-weight: 600; }
.mainnav a.on, .mainnav a:hover { background: var(--sand); color: var(--ink); text-decoration: none; }
@media (min-width: 900px) { .mainnav { display: flex; } }
.top-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

/* business switcher */
.bizswitch { display: flex; background: var(--sand); border-radius: 999px; padding: 3px; gap: 2px; }
.bizswitch a {
  padding: 5px 12px; border-radius: 999px; color: var(--ink-soft); font-weight: 600;
  font-size: .88rem; white-space: nowrap;
}
.bizswitch a:hover { text-decoration: none; color: var(--ink); }
.bizswitch a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.bizswitch a .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 5px; vertical-align: 1px; }
@media (max-width: 899px) {
  .topbar-inner { gap: 8px; flex-wrap: nowrap; padding-inline: 10px; }
  .top-end { flex: 1; min-width: 0; gap: 6px; }
  .bizswitch a { font-size: .8rem; }
  .brand img { width: 38px; height: 38px; }
  .brand span { display: none; }
  .bizswitch { flex: 1; justify-content: space-between; }
  .bizswitch a { flex: 1; text-align: center; padding: 6px 6px; }
  .top-end .logout-btn { display: none; }
}
@media (min-width: 900px) { .top-end .settings-mobile { display: none; } }
.settings-mobile:hover { text-decoration: none; }

/* bottom nav (phone) */
.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20; background: var(--card);
  border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav a {
  flex: 1; text-align: center; padding: 8px 2px 9px; color: var(--ink-soft); font-size: .74rem; font-weight: 600;
}
.bottomnav a svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }
.bottomnav a.on { color: var(--accent); }
.bottomnav a:hover { text-decoration: none; }
@media (min-width: 900px) { .bottomnav { display: none; } }

.fab {
  position: fixed; inset-inline-start: 18px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 21;
  width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 28px; box-shadow: 0 6px 18px rgba(74, 52, 38, .3);
}
.fab:hover { text-decoration: none; filter: brightness(1.08); }
@media (min-width: 900px) { .fab { bottom: 26px; } }

/* ── layout ── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 18px 16px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* KPI tiles */
.kpi .label { color: var(--ink-soft); font-size: .85rem; font-weight: 600; }
.kpi .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.kpi .sub { font-size: .82rem; color: var(--ink-soft); margin-top: 4px; }

/* business tag */
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.pill {
  display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px;
  background: var(--sand); color: var(--ink); white-space: nowrap; font-weight: 600;
}
.pill.closed { background: #e9e4dc; color: var(--ink-soft); }
.pill.won { background: #dde9d6; color: #2f5a2a; }
.pill.lost { background: #f1dcd8; color: #7b3127; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.empty { color: var(--ink-soft); padding: 8px 0; font-size: .92rem; }
.section-label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); margin: 10px 0 2px; }
.section-label.overdue { color: var(--danger); }

/* forms */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(138, 90, 59, .35); border-color: var(--accent); }
input[type=checkbox] { width: auto; min-height: 0; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.fields .full { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; min-height: 40px; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--sand); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn.icon { width: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
.inline { display: inline; margin: 0; }

/* flashes */
.flashes { max-width: 1280px; margin: 12px auto 0; padding: 0 16px; }
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-weight: 600; border: 1px solid; }
.flash.ok { background: #e9f1e4; border-color: #c9dcbf; color: #2f5a2a; }
.flash.error { background: #f6e3df; border-color: #e8c3bb; color: #7b3127; }
.flash.warn { background: #f8eed8; border-color: #ead7a8; color: #6e4c0f; }

/* leads table */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: start; font-size: .8rem; color: var(--ink-soft); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) {
  table.data th, table.data td { padding: 8px 5px; font-size: .86rem; }
}
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #fbf7ef; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); font-size: .86rem; font-weight: 600; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:hover { text-decoration: none; }

/* lead cards on phone */
.leadcards { display: none; }
@media (max-width: 699px) {
  .leadtable { display: none; }
  .leadcards { display: block; }
}
.leadcard { display: block; color: var(--ink); padding: 12px 0; border-bottom: 1px solid var(--line); }
.leadcard:last-child { border-bottom: 0; }
.leadcard:hover { text-decoration: none; }
.leadcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* score meter */
.score { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 700; }
.score .bar { width: 44px; height: 6px; border-radius: 3px; background: var(--sand); overflow: hidden; }
.score .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* kanban */
.boardhead { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; align-items: flex-start; }
.col {
  flex: 1 0 180px; max-width: 300px; background: var(--sand); border-radius: var(--radius); padding: 10px;
  scroll-snap-align: start; min-height: 120px;
}
.col.closed { opacity: .92; background: #ebe6dd; }
.col.dragover { outline: 2px dashed var(--accent); outline-offset: -4px; }
.col h3 { display: flex; justify-content: space-between; font-size: .9rem; margin: 2px 4px 10px; }
.col .count { color: var(--ink-soft); font-weight: 600; }
.kcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px;
  margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border-inline-start: 4px solid var(--bizcolor, var(--accent));
}
.kcard.dragging { opacity: .45; }
.kcard .name { font-weight: 700; color: var(--ink); display: block; }
.kcard .meta { font-size: .8rem; color: var(--ink-soft); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.kcard select { margin-top: 8px; min-height: 32px; padding: 3px 8px; font-size: .82rem; }
@media (min-width: 900px) { .kcard select { display: none; } }

/* lead page */
.leadhead { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.leadhead .who { flex: 1; min-width: 220px; }
.stagebar { display: flex; gap: 6px; flex-wrap: wrap; }
.stagebar button { font: inherit; font-size: .86rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer; }
.stagebar button.on { background: var(--bizcolor, var(--accent)); color: #fff; border-color: transparent; }
.stagebar button:hover:not(.on) { background: var(--sand); }
.convo { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.convo li { max-width: 85%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; }
.convo li.in { background: var(--sand); align-self: flex-start; border-start-start-radius: 4px; }
.convo li.out { background: #e5efe9; align-self: flex-end; border-start-end-radius: 4px; }
.convo .when { display: block; font-size: .72rem; color: var(--ink-soft); margin-top: 3px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--ink-soft); font-weight: 600; }
.kv dd { margin: 0; }
details.box > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary::after { content: " ▾"; color: var(--ink-soft); }
details.box[open] > summary { margin-bottom: 12px; }

/* tasks */
.task { display: flex; gap: 10px; align-items: flex-start; }
.task .check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--accent); background: transparent;
  cursor: pointer; flex: 0 0 auto; margin-top: 1px; padding: 0;
}
.task .check:hover { background: var(--sand); }
.task.done .title { text-decoration: line-through; color: var(--ink-soft); }
.prio-high { color: var(--danger); font-weight: 700; }
.due { font-size: .82rem; color: var(--ink-soft); }
.due.overdue { color: var(--danger); font-weight: 700; }

/* login */
.authbox { max-width: 380px; margin: 7vh auto; padding: 0 16px; text-align: center; }
.authbox img { width: 190px; height: 190px; border-radius: 18px; margin-bottom: 14px; }
.authbox form { text-align: start; }
