:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #eef0f3; --text: #1b1f24; --muted: #6b7480;
  --line: #dde1e6; --brand: #7a4b2a; --brand-text: #ffffff; --danger: #c0392b;
  --overdue: #c0392b; --today: #b7791f; --ok: #2f855a; --shadow: 0 1px 2px rgba(0,0,0,.08);
  --s-new: #6b7480; --s-contacted: #3b82f6; --s-zamer_booked: #8b5cf6; --s-zamer_done: #0ea5a4;
  --s-quote_sent: #d97706; --s-won: #2f855a; --s-lost: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1d2127; --panel-2: #262b32; --text: #e7eaee; --muted: #98a2ae;
    --line: #333a43; --brand: #c98b5b; --brand-text: #1a1206; --danger: #ef6b5b;
    --overdue: #ef6b5b; --today: #e0a83c; --ok: #48bb78; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--brand); }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* form controls */
.btn, .select, input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; }
.btn { cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.wide { width: 100%; padding: 11px; }
.btn.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger);
  padding: 8px 12px; border-radius: 8px; margin: 0; }

/* login / password pages */
body.centered { display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; }

/* top bar */
body.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; margin-right: 6px; }
.search { flex: 1 1 200px; min-width: 140px; max-width: 360px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.who form { margin: 0; }

/* board */
.board { flex: 1; display: flex; gap: 12px; padding: 14px 16px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; }
.col { flex: 0 0 272px; display: flex; flex-direction: column; background: var(--panel-2);
  border-radius: 12px; min-height: 0; scroll-snap-align: start; border: 2px solid transparent; }
.col.over { border-color: var(--brand); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.count { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; }
.col-body { flex: 1; overflow-y: auto; padding: 4px 8px 10px; display: grid; gap: 8px; align-content: start; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; box-shadow: var(--shadow); }
.card:hover { border-color: var(--brand); border-left-color: var(--c); }
.card.dragging { opacity: .4; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.card-name { overflow-wrap: anywhere; }
.rep { flex: none; font-size: 11px; font-weight: 700; background: var(--panel-2); color: var(--muted);
  border-radius: 999px; padding: 2px 7px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.badge { font-size: 11px; background: var(--panel-2); color: var(--muted); border-radius: 6px; padding: 1px 7px; }
.qual { font-size: 11px; color: var(--ok); font-weight: 600; }
.due { font-size: 12px; color: var(--muted); }
.due.overdue { color: var(--overdue); font-weight: 600; }
.due.today { color: var(--today); font-weight: 600; }
.zamer { color: var(--s-zamer_booked); }

/* lead panel */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); z-index: 11; overflow-y: auto; padding: 18px; display: grid;
  gap: 14px; align-content: start; box-shadow: -8px 0 24px rgba(0,0,0,.18); }
.drawer-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.drawer-head h2 { font-size: 20px; overflow-wrap: anywhere; }
.icon { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.pill { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; padding: 2px 10px;
  border-radius: 999px; color: #fff; background: var(--c); }
.phone { font-size: 20px; font-weight: 600; text-decoration: none; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.timeline li { border-left: 2px solid var(--line); padding-left: 12px; font-size: 14px; overflow-wrap: anywhere; }
.timeline .when { color: var(--muted); font-size: 12px; }
h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* dialog + toast */
.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text);
  padding: 22px; width: min(440px, calc(100% - 24px)); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog h3 { margin-bottom: 14px; font-size: 18px; }
.dialog .actions { justify-content: flex-end; margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 24px); }

@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .who { width: 100%; justify-content: space-between; margin-left: 0; }
  .col { flex-basis: 84vw; }
  .drawer { padding: 14px; }
}

/* navigation + admin pages */
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--panel-2); }
.nav a.on { background: var(--panel-2); color: var(--text); }
body.page { min-height: 100dvh; }
.content { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; box-shadow: var(--shadow); }
.card-box h2 { font-size: 18px; }
.card-box p { margin: 0; }
.range { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.presets { display: flex; gap: 6px; }
.field.inline { gap: 2px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.table tr.off td { opacity: .55; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.small-btn { padding: 4px 10px; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; }
.tile-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.tile.won .tile-value { color: var(--ok); }
.tile.lost .tile-value { color: var(--overdue); }
.tile-label { font-weight: 600; }
.legend { display: flex; gap: 14px; align-items: center; font-size: 13px; margin-bottom: 6px; }
.key::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; background: var(--k); }
.key.in { --k: var(--s-contacted); } .key.won { --k: var(--s-won); } .key.lost { --k: var(--s-lost); }
.bars { display: flex; gap: 4px; align-items: stretch; height: 190px; overflow-x: auto; padding-bottom: 2px; }
.bucket { flex: 1 0 22px; display: flex; flex-direction: column; min-width: 22px; }
.bar-set { flex: 1; display: flex; gap: 1px; align-items: flex-end; border-bottom: 1px solid var(--line); }
.bar { flex: 1; min-height: 1px; border-radius: 2px 2px 0 0; }
.bar.in { background: var(--s-contacted); } .bar.won { background: var(--s-won); } .bar.lost { background: var(--s-lost); }
.bar-label { font-size: 10px; color: var(--muted); height: 16px; white-space: nowrap; overflow: visible; }
.secret { display: block; font-size: 22px; letter-spacing: .04em; padding: 12px; background: var(--panel-2); border-radius: 8px; margin: 10px 0 16px; user-select: all; text-align: center; }
@media (max-width: 640px) { .nav { order: 3; width: 100%; overflow-x: auto; } }
.table td.nw { white-space: nowrap; }
.badge { white-space: nowrap; }
.table .badge { margin-left: 6px; }

/* can't reach, hints, language pickers */
.noans { font-size: 11px; font-weight: 700; color: #fff; background: var(--overdue); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.btn.warn { border-color: var(--overdue); color: var(--overdue); }
.btn.warn:hover { background: color-mix(in srgb, var(--overdue) 12%, transparent); }
.hint { margin: 0; font-size: 13px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
label[hidden], .hint[hidden] { display: none !important; }
.lang-select { padding: 4px 8px; font-size: 13px; }
.langs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.langs a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--muted); }
.langs a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-text); font-weight: 600; }

/* a call that is due right now */
.card.callnow { box-shadow: 0 0 0 2px var(--overdue); animation: callpulse 2s ease-in-out infinite; }
@keyframes callpulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--overdue) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .card.callnow { animation: none; } }
.alert-btn { padding: 8px 10px; }
.alert-btn.on { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
