:root {
  --bg: #f4f6fa; --card: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --blue: #3b5bdb; --blue-l: #e7ecff; --red: #d9480f; --green: #2b8a3e;
  --gA: #3b82f6; --gB: #f59f00; --gC: #12b886; --gD: #7048e8; --gX: #adb5bd;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: #0f172a; color: #fff; flex-wrap: wrap; }
.top a { color: #dbe4ff; }
.brand { font-weight: 700; color: #fff !important; }
.top nav { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.logout { display: flex; gap: 8px; align-items: center; margin: 0; }
.who { color: #94a3b8; font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.flash { background: #fff9db; border: 1px solid #ffe066; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.hint, .sub { color: var(--muted); font-size: 13px; }
.sub { display: block; }
.warn { color: var(--red); }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: .02em; }

.row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.row-head h1 { margin: 0; flex: 1; }

input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; }
input.bad { border-color: var(--red); background: #fff5f5; }
textarea { resize: vertical; }
button, .btn { font: inherit; padding: 8px 14px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; cursor: pointer; display: inline-block; white-space: nowrap; }
button.primary, .btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { text-decoration: none; }
button.link { border: 0; background: none; padding: 0; color: var(--blue); }
.top button.link { color: #dbe4ff; }
button.danger, .danger { color: var(--red); }
button.small, a.small { font-size: 13px; padding: 4px 8px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline select { width: auto; }
label { display: block; font-size: 13px; color: #334155; }
label > input, label > select, label > textarea, label > .with-btn { margin-top: 4px; }
label.check { display: inline-flex; gap: 6px; align-items: center; }
label.check input { width: auto; margin: 0; }
.form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.form .grid .wide { grid-column: 1 / -1; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; }

.auth { max-width: 380px; margin: 60px auto; }
.auth .card { display: grid; gap: 12px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; }
table.list td, table.list th { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list.small td { font-size: 13px; }
tr.off td { color: var(--muted); }
.search { display: flex; gap: 8px; margin-bottom: 14px; }

.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--blue); }
.stat-n { display: block; font-size: 28px; font-weight: 700; }
.stat-t { color: var(--muted); font-size: 13px; }
ul.events, ul.plain { list-style: none; padding: 0; margin: 0; }
ul.events li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ts { color: var(--muted); font-size: 12px; margin-right: 6px; }
ul.events .sub { display: inline; }
.ev-stage { font-weight: 500; }

.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { background: #e9edf5; border-radius: 10px; padding: 8px; min-width: 220px; width: 220px; flex-shrink: 0; min-height: 80px; }
.col.empty { min-width: 150px; width: 150px; opacity: .8; }
.col.over { outline: 2px dashed var(--blue); }
.col-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.col-head b { color: var(--muted); float: right; }
.deal { display: block; background: #fff; border-radius: 8px; padding: 8px; margin-bottom: 6px; color: var(--text); border: 1px solid var(--line); font-size: 13px; }
.deal:hover { text-decoration: none; border-color: var(--blue); }
.deal span { display: block; }
.grp { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--gX); }
.gA { background: var(--gA); } .gB { background: var(--gB); } .gC { background: var(--gC); } .gD { background: var(--gD); }

.deal-head { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.deal-head h1 { margin-bottom: 4px; }
.stage-box { display: grid; gap: 8px; justify-items: end; }
.stage-now { font-weight: 600; }
.stage-now .sub { display: inline; font-weight: 400; }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stage-actions form { margin: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--blue); font-weight: 600; }
.tabs a:hover { text-decoration: none; }

.doc-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.warn ul { margin: 6px 0; }
.checklist { list-style: none; padding: 0; margin: 0; display: flex; gap: 16px; flex-wrap: wrap; }
.checklist .ok { color: var(--green); } .checklist .no { color: var(--red); }
.files h2 .sub { display: inline; }
.file { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.file .sub { display: inline; flex: 1; }
.drop { margin-top: 8px; }
.drop-zone { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 12px; text-align: center; color: var(--muted); cursor: pointer; }
.drop-zone.over { border-color: var(--blue); background: var(--blue-l); }
.drop-zone input { display: none; }
.busy { opacity: .6; pointer-events: none; }

/* ничего не должно растягивать страницу шире экрана телефона */
h1 { overflow-wrap: anywhere; }
.deal-head > div, .stage-box { min-width: 0; }
form.inline { flex-wrap: wrap; }
.with-btn input { min-width: 0; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .deal-head, .stage-box, .stage-actions, .stage-actions form { width: 100%; }
  .stage-actions form.inline select { flex: 1; }
  .stage-actions form.inline button { flex: 1; }
  .form .grid { grid-template-columns: 1fr; }
  .top { gap: 10px; }
  .top nav { gap: 10px; font-size: 14px; }
  .stage-box { justify-items: start; }
  .stage-actions { justify-content: flex-start; }
  .who { display: none; }
}
