/* ===== Přátelé CRM — bleděmodrý design ===== */
:root {
  --bg: #eaf3fb;
  --card: #ffffff;
  --ink: #1f3b54;
  --muted: #6d8aa3;
  --accent: #4a90c9;
  --accent-strong: #2f6da8;
  --accent-soft: #d9eaf8;
  --border: #d7e6f2;
  --red-bg: #fbe4e4;    --red-ink: #ad5a5a;   --red-line: #e8b8b8;
  --yellow-bg: #fdf3d9; --yellow-ink: #a3812f;--yellow-line: #ecd9a4;
  --green-bg: #e1f2e5;  --green-ink: #4f8c5e; --green-line: #b9dcc2;
  --snooze-bg: #e8e9f3; --snooze-ink: #6d6f96;
  --shadow: 0 2px 12px rgba(47, 109, 168, 0.09);
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; font-weight: 650; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, #f4f9fd 0%, #ecf4fb 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(47,109,168,.06);
}
.header-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px 12px; }
.header-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.brand { font-size: 1.15rem; font-weight: 700; color: var(--accent-strong); white-space: nowrap; }
.profile-switcher { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.profile-chip {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 5px 14px; font-size: .88rem; font-weight: 600;
  transition: all .15s;
}
.profile-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(74,144,201,.35); }
.search-wrap { position: relative; }
#globalSearch {
  width: 100%; padding: 10px 40px 10px 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236d8aa3' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat 14px center;
  outline: none;
}
#globalSearch:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,144,201,.15); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 50%; width: 26px; height: 26px; line-height: 1;
}

/* ===== Layout ===== */
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.view > * + * { margin-top: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border: 1px solid rgba(215,230,242,.6);
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title h2 { font-size: 1.02rem; color: var(--accent-strong); }
.grid-2col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) {
  .grid-2col { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}

/* ===== Buttons ===== */
.btn {
  border: none; border-radius: 10px; padding: 8px 16px; font-weight: 600; font-size: .92rem;
  background: var(--accent); color: #fff; transition: filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-strong); }
.btn.ghost { background: transparent; color: var(--accent-strong); border: 1px solid var(--border); }
.btn.danger { background: var(--red-bg); color: var(--red-ink); }
.btn.small { padding: 4px 10px; font-size: .82rem; border-radius: 8px; }
.icon-btn {
  border: none; background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 8px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Status colors ===== */
.status-overdue  { --st-bg: var(--red-bg);    --st-ink: var(--red-ink);    --st-line: var(--red-line); }
.status-soon     { --st-bg: var(--yellow-bg); --st-ink: var(--yellow-ink); --st-line: var(--yellow-line); }
.status-ok       { --st-bg: var(--green-bg);  --st-ink: var(--green-ink);  --st-line: var(--green-line); }
.status-snoozed  { --st-bg: var(--snooze-bg); --st-ink: var(--snooze-ink); --st-line: #c9cbe0; }
.status-untracked{ --st-bg: #eef2f6;          --st-ink: var(--muted);      --st-line: var(--border); }
.status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .76rem; font-weight: 650;
  background: var(--st-bg); color: var(--st-ink); border: 1px solid var(--st-line);
}

/* ===== Contact rows / cards ===== */
.contact-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  border-left: 5px solid var(--st-line, var(--border));
  cursor: pointer; transition: box-shadow .15s;
}
.contact-row:hover { box-shadow: var(--shadow); }
.contact-row + .contact-row { margin-top: 8px; }
.contact-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-weight: 650; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.contact-sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.star-btn { border: none; background: none; font-size: 1.15rem; padding: 2px; opacity: .35; }
.star-btn.on { opacity: 1; }

/* Starred grid on dashboard */
.star-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.star-card {
  background: var(--st-bg, var(--accent-soft)); border: 1px solid var(--st-line, var(--border));
  border-radius: 12px; padding: 12px; cursor: pointer; position: relative; text-align: center;
}
.star-card .contact-avatar { margin: 0 auto 6px; background: rgba(255,255,255,.7); }
.star-card .nm { font-weight: 650; font-size: .92rem; word-break: break-word; }
.star-card .st { font-size: .74rem; color: var(--st-ink, var(--muted)); margin-top: 3px; }
.star-card.dragging { opacity: .4; }
.reorder-btns { position: absolute; top: 4px; right: 4px; display: flex; flex-direction: column; gap: 2px; }
.reorder-btns button, .row-reorder button {
  border: none; background: rgba(255,255,255,.75); color: var(--accent-strong);
  border-radius: 6px; width: 20px; height: 18px; font-size: .65rem; line-height: 1; padding: 0;
}
.row-reorder { display: flex; flex-direction: column; gap: 2px; }

/* ===== Tags & chips ===== */
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent-strong);
  border-radius: 6px; padding: 1px 8px; font-size: .76rem; font-weight: 600; margin: 1px 2px 1px 0;
}
.tag.small { font-size: .7rem; padding: 0 6px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: span 2; } }
.field label { display: block; font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=search], .field input[type=date], .field input[type=number],
.field input[type=password], .field select, .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: #fbfdff; outline: none;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74,144,201,.12); }
.check-line { display: flex; align-items: center; gap: 8px; font-size: .9rem; padding: 4px 0; cursor: pointer; }
.check-line input { accent-color: var(--accent); width: 16px; height: 16px; }
.inline-note { font-size: .78rem; color: var(--muted); }

/* Contact multiselect in batch form */
.multi-picker { max-height: 210px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; background: #fbfdff; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,59,84,.4); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(2px);
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal {
  background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px; box-shadow: 0 -4px 30px rgba(31,59,84,.25);
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.1rem; color: var(--accent-strong); }
.modal-body > * + * { margin-top: 12px; }

/* ===== Timeline ===== */
.timeline { border-left: 2px solid var(--accent-soft); padding-left: 14px; margin-left: 6px; }
.tl-item { position: relative; padding: 6px 0 10px; }
.tl-item::before {
  content: ""; position: absolute; left: -19.5px; top: 13px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: .84rem; }
.tl-date { font-weight: 700; color: var(--accent-strong); }
.tl-type { color: var(--muted); }
.tl-topics { font-size: .9rem; margin: 2px 0; white-space: pre-wrap; }
.tl-fu { font-size: .82rem; }
.tl-fu.done { text-decoration: line-through; color: var(--muted); }

/* ===== Follow-ups & events ===== */
.fu-line { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.fu-line:last-child { border-bottom: none; }
.fu-line input[type=checkbox] { accent-color: var(--accent); margin-top: 3px; }
.fu-who { color: var(--accent-strong); font-weight: 600; cursor: pointer; }
.event-line { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.event-line:last-child { border-bottom: none; }
.event-ico { font-size: 1.1rem; }
.event-when { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.today-banner {
  background: linear-gradient(90deg, #dceafd, #e8f4ff); border: 1px solid var(--accent-soft);
  border-radius: var(--radius); padding: 12px 16px; font-size: .95rem;
}

/* ===== Interactions list ===== */
.int-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fdfefe; }
.int-card + .int-card { margin-top: 8px; }
.int-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.int-people { font-size: .84rem; }
.int-people .who { color: var(--accent-strong); font-weight: 600; cursor: pointer; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input {
  padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); font-size: .85rem;
}

/* ===== Settings ===== */
.set-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.set-row:last-child { border-bottom: none; }
.set-row input[type=text], .set-row input[type=number] {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fbfdff;
}
.set-row .grow { flex: 1; min-width: 120px; }
.num-narrow { width: 78px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(47,109,168,.08);
}
.nav-btn {
  flex: 1; max-width: 180px; border: none; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 4px 7px; font-size: .7rem; font-weight: 650;
}
.nav-btn .nav-ico { font-size: 1.25rem; }
.nav-btn.active { color: var(--accent-strong); }
.nav-btn.active .nav-ico { transform: translateY(-1px); }

/* ===== Toast ===== */
.toast-wrap { position: fixed; bottom: 80px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--accent-strong); color: #fff; border-radius: 999px; padding: 8px 18px;
  font-size: .88rem; box-shadow: 0 4px 14px rgba(31,59,84,.3); animation: toastIn .2s ease-out;
}
.toast.err { background: var(--red-ink); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Misc ===== */
.empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 14px 6px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
[hidden] { display: none !important; }
.roulette-result { text-align: center; padding: 10px 0; }
.roulette-result .big-avatar {
  width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; margin: 0 auto 10px;
}
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
