:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.site-header .wrap { display: flex; align-items: center; gap: 28px; height: 60px; }
.site-header nav { flex: 1; }
.site-header .brand { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; gap: 18px; }
.site-header nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

main { padding-bottom: 60px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.breadcrumb { margin: 0 0 12px; font-size: 14px; }
.dash { color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 18px; }
.flash-notice { background: #e7f6ec; color: #14532d; }
.flash-alert { background: #fdecea; color: var(--danger); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.cards .card { margin-bottom: 0; }
.cards-2 { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 18px; align-items: start; }
.cards-2 .card { margin-bottom: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters .grow { flex: 1 1 240px; }

input[type="text"], input[type="search"], input[type="email"], input[type="tel"],
input[type="date"], input[type="time"], select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; resize: vertical; }

.form .field { margin-bottom: 14px; }
.form .field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.form .field input[type="text"], .form .field input[type="email"], .form .field input[type="password"],
.form .field select, .form .field textarea { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }

.nested-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.nested-row input[type="text"], .nested-row input[type="email"], .nested-row input[type="tel"] { flex: 1 1 160px; }

.btn {
  display: inline-block;
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1a3fb0; }
.btn-danger { color: var(--danger); border-color: #f0c9c4; background: #fff6f5; }
.btn-danger:hover { background: #fdecea; }
.btn-plain { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: 4px 9px; font-size: 13px; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions form { display: inline; margin: 0; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: none; }
.table-compact { border: none; }
.table-compact th, .table-compact td { padding: 5px 0; border-bottom: none; }
.table-compact th { font-weight: 600; width: 130px; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: #374151; }
.tag-type { background: #e6edff; color: #1e40af; }
.tag-region { background: #e9f5ee; color: #14532d; }
.tag-closed { background: #fdecea; color: var(--danger); }
.tag-more { background: transparent; color: var(--muted); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }

.errors { background: #fdecea; border: 1px solid #f0c9c4; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.errors h2 { color: var(--danger); text-transform: none; letter-spacing: 0; font-size: 15px; }
.errors ul { margin: 0; padding-left: 18px; }

.empty { text-align: center; padding: 60px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

@media (max-width: 720px) {
  .cards-2, .field-row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}

.subhead { font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--ink); }
.subhead:first-child { margin-top: 0; }

/* Подай сигнал */
.chat { display: flex; flex-direction: column; gap: 14px; }
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.chat-message { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }
.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-who { font-size: 12px; color: var(--muted); }
.chat-body {
  background: #f1f3f6;
  border-radius: 12px;
  padding: 10px 14px;
}
.chat-user .chat-body { background: var(--accent); color: var(--accent-ink); }
.chat-user .chat-body a { color: #cfe0ff; }
.chat-body p { margin: 0 0 8px; }
.chat-body p:last-child { margin-bottom: 0; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 14px; }
.chat-form textarea { flex: 1; }

.site-header nav .nav-aside { margin-left: auto; font-size: 13px; }

/* Вход и профил */
.auth-wrap { max-width: 420px; }
.auth-card { margin-top: 48px; }
.auth-card h1 { margin-top: 0; }
.account { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.account form { margin: 0; }
