:root {
  --bg: #f2f2f0;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #5d6470;
  --line: #d8d8d4;
  --red: #c62828;
  --yellow: #c98a00;
  --grey: #9aa0aa;
  --accent: #1f5fd0;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* никаких анимаций */
* , *::before, *::after {
  transition: none !important;
  animation: none !important;
}

a { color: var(--accent); text-decoration: none; }

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  min-height: 46px;
  width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  cursor: pointer;
  background: #fff;
  font-weight: 600;
  width: auto;
  padding: 11px 16px;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.wide { width: 100%; }
button.small { min-height: 40px; padding: 8px 12px; font-weight: 500; }

/* логин */
.login { max-width: 380px; margin: 12vh auto; padding: 16px; }
.login form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login h1 { margin: 0 0 16px; font-size: 22px; }
.login label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.login input { margin-top: 6px; }
.login button { width: 100%; background: var(--accent); color: #fff; border-color: var(--accent); }
.error { color: var(--red); margin: 0 0 12px; }

/* шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
#quick-add-btn { white-space: nowrap; flex: 0 0 auto; }
.top nav a {
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 600;
  border: 1px solid transparent;
}
.top nav a.active { background: #e9edf6; border-color: #c6d2ea; color: var(--accent); }

main { padding: 12px; max-width: 1100px; margin: 0 auto; }

h2 { font-size: 18px; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 10px 0; }

/* строки «сегодня» и списки */
.row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}
.row .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.row .name { font-weight: 700; font-size: 16px; }
.row .sub { color: var(--muted); font-size: 14px; }
.row .actions { display: flex; gap: 6px; margin-top: 10px; }
.row .actions button { flex: 1 1 52px; min-width: 52px; padding: 11px 8px; }
.row .actions button[data-act="done"] { flex: 1 1 96px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--grey); }
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.date-red { color: var(--red); font-weight: 600; }
.date-yellow { color: var(--yellow); font-weight: 600; }
.date-grey { color: var(--muted); }

/* канбан */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; }
.col {
  flex: 0 0 258px;
  background: #e8e8e4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  min-height: 140px;
}
.col.over { background: #dbe4f5; border-color: var(--accent); }
.col h3 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; }
.col h3 span { color: var(--muted); font-weight: 500; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.card .grip {
  touch-action: none;
  cursor: grab;
  color: var(--grey);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px 8px 0;
  user-select: none;
}
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 600; }
.card .company { color: var(--muted); font-size: 14px; }
.card .when { font-size: 14px; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.card.dragging { opacity: 0.35; }
.card-ghost {
  position: fixed;
  z-index: 100;
  width: 230px;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  margin: 0;
}

/* карточка контакта */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fields .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.saved { font-size: 13px; color: var(--muted); }
.notes-preview {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 60px;
  background: #fbfbf9;
  cursor: text;
}
.notes-preview p { margin: 0 0 8px; }
.notes-preview ul { margin: 0 0 8px; padding-left: 20px; }
.notes-preview code { background: #eee; padding: 1px 4px; border-radius: 4px; }

.touch { border-top: 1px solid var(--line); padding: 10px 0; }
.touch:first-of-type { border-top: 0; }
.touch .meta { font-size: 13px; color: var(--muted); }
.touch .text { white-space: pre-wrap; }

/* список */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); font-size: 15px; }
th { font-size: 13px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.mob-company { display: none; }

/* модалки */
#modal-root { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
#modal-root[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.modal .buttons { display: flex; gap: 8px; margin-top: 16px; }
.modal .buttons button { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chips button { flex: 1 1 auto; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.hint.warn { color: var(--red); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: #16181d;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 200;
  font-size: 15px;
}

@media (min-width: 720px) {
  #modal-root { align-items: center; }
  .modal { border-radius: var(--radius); }
}

@media (max-width: 560px) {
  .fields { grid-template-columns: 1fr; }
  .top nav a { padding: 9px 9px; }
  main { padding: 10px; }
  #quick-add-btn .label { display: none; }
  .col-company, .col-extra { display: none; }
  .mob-company { display: block; color: var(--muted); font-size: 13px; }
  th, td { padding: 10px 8px; }
  #quick-add-btn { font-size: 22px; line-height: 1; padding: 10px 16px; }
}


/* --- вторая версия --- */

.sep { border: 0; border-top: 2px solid var(--line); margin: 18px 0 6px; }

.promises h2.alarm { color: var(--red); }
.row.promise { border-left: 4px solid var(--grey); }
.row.promise .name { font-weight: 700; }
.promises .row.promise:has(.dot.red) { border-left-color: var(--red); }
.promises .row.promise:has(.dot.yellow) { border-left-color: var(--yellow); }

.warn-box {
  border: 2px solid var(--red);
  border-radius: var(--radius);
  background: #fdf0ef;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.warn-title { font-weight: 700; color: var(--red); margin-bottom: 4px; }
.warn-check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 15px; color: var(--ink); }
.warn-check input { width: 22px; height: 22px; min-height: 22px; }
.warn-inline {
  margin-top: 6px;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
}

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.touch .actions { display: flex; gap: 8px; margin-top: 8px; }

.picker {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  margin-top: 6px;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
}
.picker-row:last-child { border-bottom: 0; }
.picker-row input { width: 22px; height: 22px; min-height: 22px; }

.filter-chips { margin-bottom: 10px; }
.filter-chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.bulk-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.bulk-bar label { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.bulk-bar input[type="checkbox"] { width: 22px; height: 22px; min-height: 22px; }

.row.letter .head { align-items: center; }
.row.letter .head input { width: 22px; height: 22px; min-height: 22px; }
.text-preview { color: var(--muted); font-size: 14px; margin-top: 6px; white-space: pre-wrap; }

textarea.tall { min-height: 220px; }
.recipients { margin-top: 10px; }

details summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 15px;
  color: var(--accent);
  font-weight: 600;
}

button.danger { color: var(--red); border-color: #e4b9b6; }
