:root {
  --ink: #111214;
  --text: #2a2c31;
  --muted: #6c707a;
  --soft: #a3a6ae;
  --line: #e6e6e3;
  --bg: #f5f5f2;
  --card: #fff;
  --side: #0f1012;
  --yellow: #ffe600;
  --red: #e5484d;
  --orange: #f76b15;
  --amber: #f5a524;
  --green: #30a46c;
  --blue: #3e63dd;
  --r: 12px;
  --head: "Archivo", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14.5px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); color: var(--ink); margin: 0; line-height: 1.15; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #c9c9c4; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.btn-yellow:hover { background: #f5dc00; }
.btn-danger { color: var(--red); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { color: var(--blue); text-decoration: none; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

input[type=text], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
textarea { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17, 18, 20, .07); }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }

.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: var(--yellow); color: var(--ink); font: 700 14px var(--head); }

/* přihlášení */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--side); }
.login-card { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 32px; display: grid; gap: 10px; }
.login-card h1 { font-size: 28px; margin-top: 8px; }
.login-card p { margin: 0 0 10px; color: var(--muted); }
.login-card .btn { height: 44px; margin-top: 6px; }
.login-err { color: var(--red) !important; min-height: 20px; margin: 0 !important; font-size: 13px; }

/* rozložení */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: #c7c9ce; padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.side-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 8px; }
.side-brand b { font: 700 18px var(--head); color: #fff; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; text-decoration: none; font-weight: 500; color: #c7c9ce; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
.side-nav .count { background: var(--yellow); color: var(--ink); font-size: 12px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.side-mail { margin-top: auto; padding: 0 4px; }
.btn-side { width: 100%; background: rgba(255, 255, 255, .08); border-color: transparent; color: #fff; }
.btn-side:hover { background: rgba(255, 255, 255, .14); border-color: transparent; }
.side-mail p { margin: 8px 2px 0; font-size: 12.5px; color: #8b8e96; }
.side-logout { background: none; border: 0; color: #8b8e96; text-align: left; padding: 4px 8px; cursor: pointer; font-size: 13px; }
.side-logout:hover { color: #fff; }

.main { min-width: 0; padding: 28px 32px 48px; }
.main.full { padding: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.empty { color: var(--muted); padding: 14px 0; }

/* přehled */
.stage-bar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.stage-tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; text-decoration: none; }
.stage-tile b { display: block; font: 700 22px var(--head); color: var(--ink); }
.stage-tile span { font-size: 12.5px; color: var(--muted); }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; }
.list-row:first-child { border-top: 0; }
.list-row:hover .list-title { text-decoration: underline; }
.list-title { font-weight: 600; color: var(--ink); }
.list-sub { grid-column: 1 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row.unread .list-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-right: 8px; transform: translateY(-1px); }
.date { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.overdue { color: var(--red); font-weight: 600; }

.money { margin: -4px 0 18px; color: var(--muted); }
.money b { color: var(--ink); }

/* pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; min-height: calc(100vh - 140px); }
.col { background: #ecece8; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.col.drop { outline: 2px dashed var(--ink); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.col-head span { color: var(--muted); font-weight: 500; }
.lead-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; text-decoration: none; display: grid; gap: 4px; cursor: grab; }
.lead-card:hover { border-color: #c9c9c4; }
.lead-card.dragging { opacity: .5; }
.lead-card b { color: var(--ink); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.lead-card .badge { background: var(--blue); color: #fff; border-radius: 99px; font-size: 11.5px; padding: 0 7px; font-weight: 600; }
.lead-card small { color: var(--muted); font-size: 12.5px; }
.cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* detail */
.detail { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.detail-head h1 { font-size: 26px; }
.detail-links { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; font-size: 13.5px; }
.detail-head select { width: auto; min-width: 170px; font-weight: 600; }
.form-grid { display: grid; gap: 12px; }
.form-grid .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.issues { margin: 0; padding-left: 18px; color: var(--text); }
.issues li { margin: 4px 0; }
.score { display: inline-flex; align-items: baseline; gap: 6px; font: 700 22px var(--head); color: var(--ink); margin-bottom: 8px; }
.score small { font: 500 13px var(--body); color: var(--muted); }
.composer { display: grid; gap: 10px; }
.composer textarea { min-height: 280px; font-size: 14px; }
.sig { border: 1px dashed var(--line); border-radius: 9px; padding: 10px 12px; }
.sig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sig-edit { background: none; border: 0; cursor: pointer; padding: 0; }
.sig-text { white-space: pre-wrap; font-size: 13.5px; color: var(--text); }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.tl:first-child { border-top: 0; }
.tl-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--soft); margin-top: 1px; }
.tl-ico.in { background: var(--blue); }
.tl-ico.out { background: var(--ink); }
.tl-ico.stage { background: var(--amber); }
.tl-ico.note { background: var(--green); }
.tl-head { display: flex; justify-content: space-between; gap: 10px; }
.tl-title { font-weight: 600; color: var(--ink); }
.tl-body { margin-top: 4px; white-space: pre-wrap; color: var(--text); font-size: 14px; }
.tl-mail { margin-top: 6px; background: #fafaf8; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.tl-mail .tl-body { margin: 0; }
.tl-mail details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 6px; }
.note-form { display: flex; gap: 8px; margin-bottom: 6px; }

/* mapa */
.finder { display: grid; grid-template-columns: 380px minmax(0, 1fr); height: 100vh; }
.finder-panel { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.finder-panel h1 { font-size: 22px; }
.step { display: grid; gap: 8px; }
.step-title { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.radius-row { display: flex; align-items: center; gap: 12px; }
.radius-row input { flex: 1; accent-color: var(--ink); }
.radius-row output { font-weight: 600; min-width: 58px; text-align: right; }
.types { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip { position: relative; }
.type-chip input { position: absolute; opacity: 0; pointer-events: none; }
.type-chip span { display: inline-block; padding: 5px 11px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; cursor: pointer; user-select: none; }
.type-chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); margin: 0; }
.check input { accent-color: var(--ink); width: 16px; height: 16px; }
.progress { height: 6px; background: #ecece8; border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.cat-chip.off { opacity: .4; }
.results { display: grid; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.result:hover b { text-decoration: underline; }
.result b { color: var(--ink); font-weight: 600; }
.result small { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.result .sc { font-weight: 600; font-size: 13px; }
.in-crm { font-size: 11.5px; font-weight: 600; color: var(--green); }
#map { height: 100vh; background: #e8e8e4; }
#map .leaflet-tile-pane { filter: grayscale(1) contrast(.92) brightness(1.04); }
.leaflet-popup-content { margin: 14px 16px; font: 13.5px/1.45 var(--body); min-width: 240px; }
.pop h3 { font-size: 16px; margin-bottom: 2px; }
.pop .muted { margin-bottom: 8px; }
.pop ul { margin: 6px 0 10px; padding-left: 16px; }
.pop .btn { margin-top: 4px; }
.crm-pin { width: 14px; height: 14px; background: var(--yellow); border: 2px solid var(--ink); border-radius: 3px; }

/* toast a modal */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 2000; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: 90vw; }
.toast.err { background: var(--red); }
.modal { border: 0; border-radius: 14px; padding: 24px; width: min(520px, 92vw); box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
.modal::backdrop { background: rgba(15, 16, 18, .45); }
.modal h2 { font-size: 20px; margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.preview { white-space: pre-wrap; background: #fafaf8; border: 1px solid var(--line); border-radius: 9px; padding: 12px; max-height: 280px; overflow: auto; font-size: 13.5px; }

@media (max-width: 1100px) {
  .detail { grid-template-columns: 1fr; }
  .stage-bar { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; }
  .side-nav { display: flex; gap: 4px; }
  .side-mail { margin: 0; display: flex; align-items: center; gap: 8px; }
  .side-mail p { display: none; }
  .btn-side { width: auto; }
  .main { padding: 20px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .finder { grid-template-columns: 1fr; height: auto; }
  #map { height: 60vh; }
}
