:root {
  --bg: #1d1e21;
  --sidebar: #232427;
  --panel: #27282c;
  --column: #2a2b2f;
  --card: #333438;
  --card-hover: #3a3b40;
  --line: #3a3b40;
  --line-soft: #303135;
  --text: #e9e9ec;
  --text-2: #a2a4ab;
  --text-3: #75777e;
  --accent: #4f7ef7;
  --accent-hover: #6690ff;
  --danger: #e5534b;
  --radius: 10px;
  --col-w: 244px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- кнопки и поля ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  background: #3a3b40; font-weight: 600; transition: background .12s;
}
.btn:hover { background: #45464c; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(229, 83, 75, .5); }
.btn-danger:hover { background: rgba(229, 83, 75, .12); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text-2); cursor: pointer; font-size: 12px; }
.link-btn:hover { color: var(--text); }
.icon-btn {
  background: none; border: 0; color: var(--text-2); cursor: pointer; width: 26px; height: 26px;
  border-radius: 6px; display: inline-grid; place-items: center; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--text); }

input, select, textarea {
  background: #1f2023; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; width: 100%; }

/* ---------- вход ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 340px; max-width: 100%; background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.login-card .brand-logo { align-self: center; margin: 4px 0 10px; }
.login-title { font-size: 17px; font-weight: 700; }

/* логотип: картинка smartarena + слово tracker тем же шрифтом (Urbanist Light) */
.brand-logo {
  --h: 27px;
  display: inline-flex; align-items: flex-end; text-decoration: none; color: #fff; user-select: none;
}
.brand-logo img { height: var(--h); display: block; }
.brand-logo span {
  font-family: Urbanist, "Segoe UI", sans-serif; font-weight: 300; line-height: 1; letter-spacing: .005em;
  font-size: calc(var(--h) * .61); margin-left: calc(var(--h) * .16); padding-bottom: calc(var(--h) * .255);
}
.brand-logo.lg { --h: 40px; }

.board-badge {
  --c: #4cc27a;
  width: 22px; height: 22px; border-radius: 6px; flex: none; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 12px; color: var(--c); background: color-mix(in srgb, var(--c) 20%, transparent);
}
.board-badge.md { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; }
.board-badge.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }
.form-error { color: var(--danger); min-height: 16px; }
.form-error:empty { display: none; }
.form-ok { color: #9fe2b6; background: rgba(76,194,122,.12); border: 1px solid #2f6b45; border-radius: 8px; padding: 9px 11px; }
.login-switch { color: var(--text-3); text-align: center; font-size: 12px; }
.login-switch .link-btn { color: var(--accent-hover); font-weight: 600; }
.badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}
.pending { border: 1px solid #4a5c94; background: rgba(79,126,247,.08); border-radius: var(--radius); padding: 4px 12px 8px; margin: 10px 0 6px; }
.pending h2 { margin-top: 10px; }

/* ---------- каркас ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 228px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.sidebar > .brand-logo { padding: 6px 8px 18px; }
.btn-create { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-create span { font-size: 17px; line-height: 1; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: rgba(255,255,255,.05); }
.nav a.active { background: #34416a; }
.nav-ico { width: 16px; text-align: center; color: var(--text-2); }
.nav-section {
  display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding: 0 4px 0 10px;
  color: var(--text-3); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.boards-nav { margin-top: 0; overflow-y: auto; min-height: 0; flex: 0 1 auto; }
.boards-nav a { font-weight: 500; padding: 6px 10px; }
.boards-nav a span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding: 12px 6px 0; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.me small { display: block; color: var(--text-3); font-weight: 400; }
.me-actions { display: flex; gap: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 12px; }
.head-btn { margin-left: auto; }
.crumbs { color: var(--text-2); font-size: 12px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs b { color: var(--text); }

/* ---------- список досок ---------- */
.panel.wide { max-width: none; }
.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding-top: 6px; }
.board-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 12px; min-height: 76px;
  background: var(--panel); border: 1px solid var(--line-soft); color: var(--text); text-decoration: none; cursor: pointer;
}
.board-card:hover { background: #2e2f34; border-color: var(--line); }
.board-card.new { justify-content: center; border-style: dashed; color: var(--text-2); font-weight: 600; font-size: 14px; }
.board-card.new:hover { color: var(--text); }
.bc-name { font-weight: 700; font-size: 15px; }
.bc-meta { color: var(--text-3); font-size: 12px; margin-top: 3px; }

.hint { color: var(--text-3); font-size: 12px; }
.hint b { color: var(--text-2); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 26px; height: 26px; border-radius: 8px; background: var(--c); cursor: pointer; border: 2px solid transparent; }
.swatch input:checked + span { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { margin: 2px 0 0; font-size: 20px; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- тулбар ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 22px; border-top: 1px solid var(--line-soft);
}
.search {
  display: flex; align-items: center; gap: 6px; background: #1f2023; border: 1px solid var(--line);
  border-radius: 8px; padding: 0 10px; width: 300px; max-width: 100%;
}
.search span { color: var(--text-3); }
.search input { border: 0; background: none; padding: 7px 0; flex: 1; min-width: 0; }
.select-wrap { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.select-wrap select { padding: 6px 8px; color: var(--text); }

.type-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 22px 12px; border-bottom: 1px solid var(--line-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #2a2b2f;
  border-radius: 999px; padding: 4px 11px; cursor: pointer; color: var(--text-2); font-weight: 600; user-select: none;
}
.chip:hover { color: var(--text); }
.chip.on { background: #34416a; border-color: #4a5c94; color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .cnt { color: var(--text-3); font-weight: 500; }

/* ---------- доска ---------- */
.board-wrap { flex: 1; min-height: 0; overflow: auto; padding: 14px 22px 22px; }
.board { display: inline-flex; flex-direction: column; min-width: 100%; }
.col-heads, .lane-cells { display: grid; grid-template-columns: repeat(var(--cols), var(--col-w)); gap: 8px; }
.col-heads { position: sticky; top: -14px; z-index: 3; background: var(--bg); padding-top: 0; }
.col-head {
  background: var(--column); border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; gap: 6px; padding: 12px 10px 10px 12px;
}
.col-head .name { font-weight: 700; font-size: 14px; }
.col-head .cnt { color: var(--text-3); }
.col-head .icon-btn { margin-left: auto; }

.lane { margin-top: 0; }
.lane-head {
  position: sticky; left: 0; display: flex; align-items: center; gap: 8px; width: max-content;
  padding: 12px 4px 8px; cursor: pointer; font-weight: 700; user-select: none;
}
.lane-head .caret { color: var(--text-3); transition: transform .12s; display: inline-block; }
.lane.collapsed .caret { transform: rotate(-90deg); }
.lane.collapsed .lane-cells { display: none; }
.lane-head .cnt { color: var(--text-3); font-weight: 500; }
.lane-head .dot { width: 10px; height: 10px; border-radius: 3px; }

.cell {
  background: var(--column); padding: 4px 6px 8px; min-height: 60px;
  display: flex; flex-direction: column; gap: 6px;
}
.board.flat .cell { border-radius: 0 0 var(--radius) var(--radius); min-height: calc(100vh - 290px); }
.board.grouped .cell { border-radius: var(--radius); }
.board.grouped .col-heads .col-head { border-radius: var(--radius); }
.cell.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: #2c3141; }

.card {
  background: var(--card); border: 1px solid #3c3d42; border-radius: 8px; padding: 9px 10px 10px;
  cursor: pointer; display: flex; flex-direction: column; gap: 7px;
}
.card:hover { background: var(--card-hover); }
.card.dragging { opacity: .4; }
.card-top { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 12px; }
.card-key { font-weight: 600; }
.card.closed .card-key { text-decoration: line-through; }
.card-top .prio { margin-left: auto; display: inline-flex; }
.card-title { font-weight: 600; font-size: 13px; word-break: break-word; }
.card-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.avatar {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 9px; font-weight: 700; color: #fff; text-transform: uppercase;
}
.avatar.lg { width: 28px; height: 28px; font-size: 11px; }
.avatar.empty { background: transparent; border: 1px dashed var(--text-3); color: var(--text-3); }

.type-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--text-2);
}
.type-badge .dot { width: 7px; height: 7px; border-radius: 50%; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.st-open { color: #b5b7bd; background: rgba(255,255,255,.07); }
.st-open::before { border-style: dashed; }
.st-pause { color: #f2c94c; background: rgba(242,201,76,.15); }
.st-progress { color: #78a2ff; background: rgba(79,126,247,.18); }
.st-progress::before { background: currentColor; width: 6px; height: 6px; box-shadow: 0 0 0 2px rgba(120,162,255,.35); border: 0; }
.st-review { color: #c49bff; background: rgba(180,107,232,.17); }
.st-closed { color: #4cc27a; background: rgba(76,194,122,.15); }
.st-backlog { color: #9a9ca3; background: rgba(255,255,255,.06); }
.st-backlog::before { border-style: dotted; }

.empty-col { color: var(--text-3); text-align: center; padding: 14px 0; font-size: 12px; }

/* ---------- панели (участники, типы) ---------- */
.panel { padding: 8px 22px 30px; overflow: auto; max-width: 860px; }
.panel h2 { font-size: 15px; margin: 18px 0 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 6px; }
.user-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.tag { font-size: 11px; color: #c49bff; background: rgba(180,107,232,.15); border-radius: 6px; padding: 1px 7px; margin-left: 6px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px; }
.inline-form input[type=text], .inline-form input[type=password], .inline-form input:not([type]) { width: 170px; }
.inline-form label.check { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
input[type=color] { padding: 2px; width: 38px; height: 32px; cursor: pointer; }
.muted { color: var(--text-3); }

/* ---------- модалка ---------- */
.overlay {
  /* minmax(0, 1fr): колонка равна ширине экрана, иначе широкое содержимое растягивает окно за его край */
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  place-items: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 860px; max-width: 100%; min-width: 0; min-height: 0;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal.sm { width: 400px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); color: var(--text-2); font-weight: 600; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 20px; }
.modal.sm .modal-body { grid-template-columns: minmax(0, 1fr); }
.modal-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.title-input { font-size: 18px; font-weight: 700; padding: 8px 10px; width: 100%; }
.modal-main textarea { min-height: 260px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 5px; color: var(--text-2); font-size: 12px; }
.field select, .field input { width: 100%; color: var(--text); font-size: 13px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.meta { color: var(--text-3); font-size: 12px; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.modal-foot .spacer { flex: 1; }

/* ---------- комментарии ---------- */
.modal.has-comments .modal-main textarea[name=description] { min-height: 130px; }
.comments { border-top: 1px solid var(--line-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.comments-head { font-weight: 700; font-size: 14px; }
.comments-head .cnt { color: var(--text-3); font-weight: 500; margin-left: 4px; }
.c-list { display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 10px; }
.comment > .avatar { width: 28px; height: 28px; font-size: 11px; }
.c-main { flex: 1; min-width: 0; }
.c-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.c-head b { font-size: 13px; }
.c-actions { margin-left: auto; display: flex; gap: 12px; opacity: 0; transition: opacity .12s; }
.comment:hover .c-actions, .c-actions:focus-within { opacity: 1; }
@media (hover: none) { .c-actions { opacity: 1; } }
.c-text { margin-top: 4px; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.c-text a { color: var(--accent-hover); }
.c-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.c-img { max-width: 100%; }
.c-img img {
  display: block; max-height: 160px; max-width: min(260px, 100%); border-radius: 8px; border: 1px solid var(--line);
  background: #1f2023; cursor: zoom-in;
}
.c-img:hover img { border-color: var(--accent); }
.c-edit textarea { min-height: 70px; margin-top: 6px; }
.c-edit-bar { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

.composer {
  border: 1px solid var(--line); border-radius: 10px; background: #1f2023; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.composer:focus-within { border-color: #4a5c94; }
.composer.drop { border-color: var(--accent); border-style: dashed; background: #232a3d; }
.composer textarea { border: 0; background: none; padding: 4px; min-height: 64px; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.composer-bar .spacer { flex: 1; }
.attach-btn { display: inline-flex; align-items: center; gap: 6px; }
.c-pending { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 4px; }
.c-pending:empty { display: none; }
.pend { position: relative; }
.pend img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.pend.uploading img { opacity: .35; }
.pend.uploading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
.pend button {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: #55565c; color: #fff; cursor: pointer; line-height: 1; font-size: 14px; padding: 0;
}
.pend button:hover { background: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.c-count { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 600; margin-left: auto; }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.88); display: grid; place-items: center;
  padding: 24px 24px 56px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 90px); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lb-open {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; text-decoration: none;
  background: rgba(255,255,255,.12); padding: 6px 14px; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.lb-open:hover { background: rgba(255,255,255,.2); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #3b2526; color: #ffb4ae;
  border: 1px solid #6b3434; padding: 10px 16px; border-radius: 10px; z-index: 100; font-weight: 600;
}
.toast.ok { background: #233528; color: #9fe2b6; border-color: #2f6b45; }

/* ---------- узкие экраны ---------- */
@media (max-width: 760px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
  .sidebar > .brand-logo { padding: 0 8px 0 0; }
  .nav-section, .boards-nav { display: none; }
  .page-head { flex-wrap: wrap; }
  .btn-create { width: auto; }
  .nav { flex-direction: row; margin: 0; flex-wrap: wrap; }
  .nav-ico { display: none; }
  .sidebar-foot { border: 0; padding: 0; margin: 0 0 0 auto; }
  .me { display: none; }
  .page-head, .toolbar, .type-chips, .board-wrap, .panel { padding-left: 16px; padding-right: 16px; }
  .board-wrap { min-height: 70vh; }
  .board.flat .cell { min-height: 200px; }

  /* окна на телефоне — во весь экран, поля в одну колонку: название, параметры, описание, комментарии */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.sm { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .modal-head { padding: 12px 8px 12px 16px; }
  .modal-head .icon-btn { width: 40px; height: 40px; font-size: 24px; }
  .modal-body, .modal.sm .modal-body { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; gap: 14px; align-content: start; }
  .modal-main { display: contents; }
  .title-input { order: 0; font-size: 17px; }
  .side { order: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .side .meta { grid-column: 1 / -1; }
  .modal-main > .field { order: 2; }
  .modal.has-comments .modal-main textarea[name=description], .modal .modal-main textarea[name=description] { min-height: 110px; }
  .comments { order: 3; }
  .modal-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .modal-foot .muted, .composer-bar .muted { display: none; }
  /* 16px — чтобы iOS не увеличивал страницу при фокусе на поле */
  input, select, textarea, .field select, .field input { font-size: 16px; }
}
