:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d232b; --muted: #667080; --line: #e3e6eb;
  --accent: #e08a00; --accent-2: #b86f00; --accent-soft: #fff4e0;
  --ok: #1f8a4c; --warn: #c26a00; --bad: #c0392b; --link: #1f5fbf;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1c2026; --text: #e7eaee; --muted: #9aa3ae; --line: #2c323a;
    --accent: #f0a020; --accent-2: #ffb84d; --accent-soft: #3a2c12; --link: #7fb0ff; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

header.top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
@media (max-width: 700px) { header.top .brand { display: none; } header.top nav a { padding: 12px 8px; } }
header.top .brand { font-weight: 700; margin-right: 10px; white-space: nowrap; color: var(--text); }
header.top .brand span { color: var(--accent); }
header.top nav { display: flex; flex-wrap: nowrap; }
header.top nav a { display: inline-block; padding: 14px 10px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
header.top nav a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
header.top nav a:hover { text-decoration: none; color: var(--text); }
header.top .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.badge-test { background: var(--accent-soft); color: var(--accent-2); border-radius: 20px; padding: 3px 10px; font-size: 12px; white-space: nowrap; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.flash { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.card { grid-template-columns: 1.1fr 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.table-wrap { overflow-x: auto; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .btn, .row > button { flex: 0 0 auto; }
form.inline { display: inline; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.tag.stage { background: var(--accent-soft); border-color: transparent; color: var(--accent-2); }
.tag.bad { color: var(--bad); }
.tag.ok { color: var(--ok); }
.overdue { color: var(--bad); font-weight: 600; }

.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { flex: 0 0 240px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.col h3 { margin: 0; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 6px; }
.col .cards { padding: 8px; min-height: 60px; max-height: 70vh; overflow-y: auto; }
.col.drop { outline: 2px dashed var(--accent); }
.kcard { display: block; background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; color: var(--text); font-size: 13px; cursor: grab; }
.kcard:hover { text-decoration: none; outline: 1px solid var(--line); }
@media (max-width: 700px) {
  .kanban { flex-direction: column; }
  .col { flex-basis: auto; width: 100%; }
  .col .cards { max-height: 260px; }
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; font-size: 14px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.kind-reply { border-left: 3px solid var(--ok); padding-left: 8px !important; }
.kind-form { border-left: 3px solid var(--accent); padding-left: 8px !important; }

details { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; }
.fields { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 600px) { .fields { grid-template-columns: 1fr 1fr; } }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* публичные формы */
.pub { max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; }
.pub .logo { font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.pub .logo span { color: var(--accent); }
.err { color: var(--bad); font-size: 13px; margin-top: 3px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.slots label { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); background: var(--panel); cursor: pointer; font-size: 14px; }
.slots input { width: auto; margin-right: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { width: auto; margin-top: 3px; }
