:root {
  --bg: #0C0E18;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(127, 102, 255, 0.10);
  --border: #212745;
  --border-strong: #2c3358;
  --accent: #7F66FF;
  --accent-hover: #6f56f0;
  --accent-tint: rgba(127, 102, 255, 0.15);
  --text: #FFFFFF;
  --muted: #A3A8C2;
  --ok: #5DCAA5;
  --ok-bg: rgba(93, 202, 165, 0.12);
  --err: #FF8095;
  --err-bg: rgba(255, 128, 149, 0.12);
  --radius: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app-header {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.app-header h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.2px; }
.subtitle { margin: 1px 0 0; font-size: 11px; color: var(--muted); font-weight: 500; }

main { padding: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 14px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted);
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: rgba(163, 168, 194, 0.55); }
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

.checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--muted); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: default; }

.hidden { display: none; }

/* Список объектов — современные строки с чипом типа */
.entity-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-y: auto;
  max-height: 240px;
  background: var(--surface-2);
}
.entity-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.entity-row:last-child { border-bottom: none; }
.entity-row:hover { background: var(--surface-hover); }
.entity-row.selected { background: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.entity-check {
  flex: 0 0 auto;
  width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: transparent; line-height: 1;
}
.entity-row.selected .entity-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.entity-name {
  font-size: 12px; font-weight: 500; color: var(--text);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entity-type {
  flex: 0 0 auto;
  font-size: 9px; font-weight: 600; letter-spacing: 0.2px;
  padding: 2px 6px; border-radius: 20px;
  background: var(--accent-tint); color: #b7a9ff;
  white-space: nowrap; text-transform: uppercase;
}
.entity-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }
.count-badge {
  font-weight: 700; color: var(--accent);
}

.hint { margin: -6px 0 14px; font-size: 12px; color: var(--muted); }

.badge-unf {
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 20px; vertical-align: middle;
  background: var(--accent-tint); color: #b7a9ff;
}

input[type="date"] { color-scheme: dark; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-btn {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 12px; font-weight: 500;
  text-align: left; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.preset-btn:hover { border-color: var(--accent); background: var(--surface-hover); }
.preset-btn:disabled { opacity: 0.5; cursor: default; }

.status {
  margin: 0 14px 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  display: none;
}
.status.show { display: block; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.err { background: var(--err-bg); color: var(--err); }
.status.info { background: var(--surface-2); color: var(--muted); }

/* тонкий скроллбар в тёмной теме */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
