:root {
  --bg: #f7f8f7; --card: #fff; --ink: #17211e; --muted: #66736f; --line: #e3e7e5; --soft: #eef2f0;
  --accent: #0d6a56; --accent-ink: #fff; --accent-soft: #e3f1ed; --warn: #a4530b; --warn-soft: #fbeedd;
  --bad: #a3312b; --bad-soft: #fae9e7; --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 12px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* shell */
.top { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 54px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand i { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: grid; place-items: center; }
.brand i svg { width: 14px; height: 14px; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--soft); text-decoration: none; }
.nav a.on { color: var(--accent); background: var(--accent-soft); }
.who { color: var(--muted); font-size: 13px; background: none; border: 0; cursor: pointer; padding: 6px; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 90px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .grow { flex: 1; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 13px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: #c9d1ce; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=datetime-local], input[type=tel], input[type=email], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; min-height: 40px; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: 13px; font-weight: 550; color: var(--muted); margin: 12px 0 5px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 550; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 13px; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag.s-emailed, .tag.s-called { background: #e8eef7; color: #2d4f85; }
.tag.s-replied { background: var(--warn-soft); color: var(--warn); }
.tag.s-booked, .tag.s-audit, .tag.s-won { background: var(--accent-soft); color: var(--accent); }
.tag.s-lost { background: var(--bad-soft); color: var(--bad); }
.av { width: 22px; height: 22px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.av.u1 { background: var(--accent-soft); color: var(--accent); }
.av.u2 { background: #efe8f6; color: #5d3d8a; }
.due { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.late { color: var(--bad); }
.due.today { color: var(--warn); }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

/* today */
.group { margin-bottom: 22px; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .name { font-weight: 600; color: var(--ink); }
.task .acts { display: flex; gap: 6px; grid-row: span 2; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

/* pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
.col { background: var(--soft); border-radius: var(--radius); padding: 10px; min-height: 220px; scroll-snap-align: start; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { margin: 2px 4px 10px; font-size: 13px; display: flex; justify-content: space-between; font-weight: 650; }
.col h3 b { color: var(--muted); font-weight: 500; }
.deal { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; margin-bottom: 8px; color: var(--ink); cursor: pointer; }
.deal:hover { border-color: #c2ccc8; text-decoration: none; }
.deal .n { font-weight: 600; line-height: 1.25; }
.deal .p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.deal .step { font-size: 13px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); }
.deal .foot { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.deal .foot .grow { flex: 1; }
.parked { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafbfa; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* agency */
.two { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.person { padding: 10px 0; border-bottom: 1px solid var(--line); }
.person:first-of-type { padding-top: 0; }
.person:last-of-type { border-bottom: 0; }
.person .nm { font-weight: 600; }
.num { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.num a.call { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 6px 11px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.num a.call:hover { text-decoration: none; background: #d5eae4; }
.logbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tl { position: relative; padding-left: 26px; }
.tl::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.ev { position: relative; padding-bottom: 16px; }
.ev:last-child { padding-bottom: 0; }
.ev::before { content: ""; position: absolute; left: -22px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid #b9c4c0; }
.ev.t-call::before, .ev.t-booking::before, .ev.t-reply::before { border-color: var(--accent); background: var(--accent); }
.ev .hd { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ev .hd b { font-weight: 600; }
.ev .x { margin-left: auto; opacity: 0; }
.ev:hover .x, .ev:focus-within .x { opacity: 1; }
.mail { margin-top: 6px; }
.mail summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 550; }
.mailbody { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-top: 8px; font-size: 14px; max-width: 640px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(15,25,22,.38); z-index: 20; display: grid; place-items: center; padding: 16px; }
.sheet { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.sheet h3 { margin: 0; font-size: 18px; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; position: sticky; bottom: -20px; background: #fff; padding: 12px 0 0; }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#toast.on { opacity: 1; }

/* login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; }
.login .card { padding: 24px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }

@media (max-width: 760px) {
  .top { backdrop-filter: none; background: #fff; }
  .top-in { padding: 0 14px; height: 50px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; z-index: 6; }
  .nav a { flex: 1; text-align: center; padding: 9px 4px; font-size: 14px; }
  .brand { flex: 1; }
  main { padding: 16px 14px 100px; }
  .two { grid-template-columns: 1fr; }
  .board { grid-auto-columns: 78vw; }
  .hide-m { display: none; }
  .scrim { align-items: end; padding: 0; }
  .sheet { border-radius: 16px 16px 0 0; max-width: none; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .task { grid-template-columns: 1fr; }
  .task .acts { grid-row: auto; margin-top: 6px; }
  .task .acts .btn { flex: 1; text-align: center; padding: 10px; }
  .ev .x { opacity: 1; }
  input, select, textarea { font-size: 16px !important; }
}
