:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --col: #e9ebf0;
  --col-today: #e3e6ff;
  --text: #1c1f26;
  --muted: #6b7180;
  --border: #d9dce4;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --danger: #d4372c;
  --danger-bg: #fdecea;
  --shadow: 0 1px 2px rgba(20, 24, 40, .08), 0 1px 1px rgba(20, 24, 40, .04);
  --shadow-lg: 0 20px 50px rgba(20, 24, 40, .25);
  --wb: #a733c9;
  --ozon: #1a6dff;
  --ym: #f5b400;
  --other: #8a90a0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #22252d;
    --surface-2: #2b2f38;
    --col: #1b1e24;
    --col-today: #23264a;
    --text: #e8eaf0;
    --muted: #9298a6;
    --border: #353a45;
    --accent: #7c74ff;
    --danger: #ff6b5f;
    --danger-bg: #3a1f1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-size: 13px; }

/* ---------- кнопки и поля ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.icon { width: 34px; padding: 7px 0; font-size: 18px; line-height: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-soft { background: var(--danger-bg); border-color: transparent; color: var(--danger); font-weight: 600; }
input, textarea, .select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, textarea:focus, .select:focus, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; }

/* ---------- вход ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 28px; display: grid; gap: 12px;
}
.login-card p { margin: 0 0 6px; }

/* ---------- шапка ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand.big { font-size: 20px; }
.logo {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  background-image: linear-gradient(white, white), linear-gradient(white, white), linear-gradient(white, white);
  background-size: 12px 2.5px, 12px 2.5px, 8px 2.5px;
  background-position: 5px 6px, 5px 10px, 5px 14px;
  background-repeat: no-repeat;
}
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav h1 { font-size: 16px; margin: 0 0 0 8px; font-weight: 600; }
.tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tools .select { width: auto; min-width: 180px; padding: 7px 10px; }

/* ---------- доска ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  align-items: start;
  min-height: calc(100vh - 56px);
}
.column {
  background: var(--col);
  border-radius: 12px;
  padding: 8px;
  display: flex; flex-direction: column;
  min-height: 160px;
  border: 2px solid transparent;
  transition: border-color .12s;
}
.column.today { background: var(--col-today); }
.column.weekend .col-head .day { color: var(--muted); }
.column.drag-over { border-color: var(--accent); }
.col-head { display: flex; align-items: baseline; gap: 6px; padding: 4px 6px 8px; white-space: nowrap; }
.col-head .day { font-weight: 700; text-transform: capitalize; }
.col-head .date { color: var(--muted); font-size: 13px; }
.col-head .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.today .col-head .date { color: var(--accent); font-weight: 600; }
.cards { display: flex; flex-direction: column; gap: 6px; min-height: 8px; }

.card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  cursor: pointer;
  display: grid; gap: 6px;
  border-left: 4px solid transparent;
  word-break: break-word;
}
.card:hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.card.dragging { opacity: .4; }
.card.label-wb { border-left-color: var(--wb); }
.card.label-ozon { border-left-color: var(--ozon); }
.card.label-ym { border-left-color: var(--ym); }
.card.label-other { border-left-color: var(--other); }
.card.done .card-title { text-decoration: line-through; color: var(--muted); }
.card.overdue { box-shadow: 0 0 0 1px var(--danger), var(--shadow); }
.card-top { display: flex; gap: 8px; align-items: flex-start; }
.card-title { flex: 1; }
.card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2); }
.chip.time.overdue { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.chip.mp { color: #fff; font-weight: 600; }
.chip.mp.wb { background: var(--wb); }
.chip.mp.ozon { background: var(--ozon); }
.chip.mp.ym { background: var(--ym); color: #2a2100; }
.chip.mp.other { background: var(--other); }
.avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.assignee { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--text); }

/* чекбокс */
.check { position: relative; display: inline-block; width: 18px; height: 18px; flex: none; margin-top: 1px; }
.check input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check span { position: absolute; inset: 0; border: 2px solid var(--border); border-radius: 5px; background: var(--surface); pointer-events: none; }
.check input:checked + span { background: #22a35a; border-color: #22a35a; }
.check input:checked + span::after {
  content: ""; position: absolute; left: 4px; top: 0px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.big-check { width: 22px; height: 22px; margin-top: 6px; }
.big-check input:checked + span::after { left: 6px; top: 1px; width: 6px; height: 12px; }

/* быстрое добавление */
.add-btn {
  margin-top: 6px; text-align: left; color: var(--muted);
  background: transparent; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer; font: inherit;
}
.add-btn:hover { background: var(--surface-2); color: var(--text); }
.quick-add { margin-top: 6px; display: grid; gap: 6px; }
.quick-add textarea { resize: none; box-shadow: var(--shadow); }
.quick-add .row { display: flex; gap: 6px; align-items: center; }

/* ---------- диалоги ---------- */
.dialog {
  border: 0; border-radius: 14px; padding: 0;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 12, 20, .45); }
.dialog form, .dialog > .dialog-head, .overdue-list { padding: 18px 20px; }
.dialog form { display: grid; gap: 14px; }
.dialog-head { display: flex; gap: 10px; align-items: flex-start; }
.dialog > .dialog-head { padding-bottom: 0; }
.dialog-head h2 { margin: 4px 0 0; font-size: 18px; flex: 1; }
.title-input { font-size: 18px; font-weight: 600; border-color: transparent; resize: none; padding: 4px 8px; flex: 1; }
.title-input:hover { border-color: var(--border); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.dialog-foot { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.overdue-list { display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.overdue-list .card { grid-template-columns: 1fr; }
.empty { color: var(--muted); padding: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: #1c1f26; color: #fff; padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- мобильные ---------- */
@media (max-width: 760px) {
  .topbar { gap: 10px; }
  .tools { margin-left: 0; width: 100%; }
  .tools .select { flex: 1; min-width: 0; }
  .week-nav { width: 100%; }
  .week-nav h1 { font-size: 15px; }
  .board {
    grid-template-columns: repeat(7, 82vw);
    scroll-snap-type: x mandatory;
    padding: 12px 16px;
  }
  .column { scroll-snap-align: center; }
  .grid2 { grid-template-columns: 1fr; }
}
