:root{--bg:#0f172a;--panel:#111827;--card:#1f2937;--text:#e5e7eb;--muted:#9ca3af;--line:#334155;--blue:#2563eb;--green:#16a34a;--yellow:#ca8a04;--red:#dc2626;--accent:#38bdf8}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}.topbar{position:sticky;top:0;z-index:2;display:flex;align-items:center;justify-content:space-between;background:#020617;border-bottom:1px solid var(--line);padding:12px 18px}.brand{font-weight:800;font-size:22px;color:#fff;text-decoration:none}.topbar nav{display:flex;gap:10px;flex-wrap:wrap}.topbar nav a{color:var(--text);text-decoration:none;padding:8px 10px;border-radius:10px;background:#111827}.topbar nav a.export{background:var(--blue)}.container{max-width:1200px;margin:0 auto;padding:18px}.hero h1{margin:8px 0 4px;font-size:32px}.hero p,.muted{color:var(--muted)}.stats{display:grid;grid-template-columns:repeat(5,1fr);gap:10px;margin:18px 0}.stat{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px;text-decoration:none;color:var(--text)}.stat b{display:block;font-size:28px}.stat span{color:var(--muted)}.stat.blue{border-color:var(--blue)}.stat.green{border-color:var(--green)}.stat.yellow{border-color:var(--yellow)}.stat.red{border-color:var(--red)}.filters{display:grid;grid-template-columns:1fr 180px 180px 100px 80px;gap:8px;margin:14px 0}.filters input,.filters select,.edit-form input,.edit-form select,.edit-form textarea{width:100%;background:#020617;border:1px solid var(--line);border-radius:12px;color:var(--text);padding:12px;font-size:16px}.filters button,.panel button,.save{border:0;border-radius:12px;background:var(--accent);color:#001018;font-weight:700;padding:12px 14px;font-size:16px}.clear{display:flex;align-items:center;justify-content:center;text-decoration:none;color:var(--muted)}.quick{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0}.quick a{background:#0b1220;border:1px solid var(--line);color:var(--text);text-decoration:none;border-radius:999px;padding:10px 14px}.cards{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}.person-card{display:block;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px;color:var(--text);text-decoration:none}.person-card:hover{border-color:var(--accent)}.card-row{display:flex;gap:10px;justify-content:space-between;align-items:flex-start}.badge{font-size:13px;padding:4px 8px;border-radius:999px;background:#0b1220;color:#fff;white-space:nowrap}.place{margin-top:8px;color:#dbeafe}.reason{margin-top:8px;color:#fde68a}.person-page{display:grid;grid-template-columns:1fr 380px;gap:18px}.profile,.edit-form,.panel,.log-block{background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:18px}.info-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin:14px 0}.info-grid div{background:#020617;border:1px solid var(--line);padding:12px;border-radius:12px}.info-grid span{display:block;color:var(--muted);font-size:13px}.note{background:#0b1220;border-left:4px solid var(--accent);padding:12px;border-radius:8px}.edit-form{display:flex;flex-direction:column;gap:10px}.checkbox{display:flex;gap:10px;align-items:center;background:#020617;border:1px solid var(--line);border-radius:12px;padding:12px}.checkbox input{width:22px;height:22px}.back{color:var(--accent);text-decoration:none;display:inline-block;margin-bottom:12px}.log-block{margin-top:18px}.log-item{padding:10px;border-bottom:1px solid var(--line)}
@media(max-width:800px){.topbar{display:block}.topbar nav{margin-top:10px}.stats{grid-template-columns:repeat(2,1fr)}.filters{grid-template-columns:1fr}.cards{grid-template-columns:1fr}.person-page{grid-template-columns:1fr}.info-grid{grid-template-columns:1fr}.container{padding:12px}.hero h1{font-size:26px}.topbar nav a{font-size:14px}.stat b{font-size:24px}}

/* --- table module --- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(130px, 1fr)) auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.filters input,
.filters select,
.mini-input,
.wide-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 9px 10px;
}

.table-actions,
.bottom-save {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0;
}

.wide-table-wrap {
  overflow-x: auto;
  border: 1px solid #1f2937;
  border-radius: 14px;
}

.wide-table {
  width: 100%;
  min-width: 1900px;
  border-collapse: collapse;
  font-size: 14px;
}

.wide-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #111827;
  color: #f9fafb;
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #334155;
}

.wide-table td {
  padding: 7px;
  border-bottom: 1px solid #1f2937;
  vertical-align: top;
}

.wide-table tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.name-cell {
  min-width: 230px;
  font-weight: 700;
  color: #f8fafc;
}

.center {
  text-align: center;
}

.small-link {
  color: #93c5fd;
  font-weight: 700;
  text-decoration: none;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #475569;
}

@media (max-width: 900px) {
  .page-head {
    display: block;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}

/* --- table v2 --- */
.quick-buttons {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.quick-card {
  display: block;
  text-align: center;
  padding: 14px 10px;
  border-radius: 14px;
  text-decoration: none;
  color: #e5e7eb;
  background: #111827;
  border: 1px solid #334155;
  font-weight: 800;
}

.quick-card:hover {
  background: #1e293b;
}

.quick-card.danger {
  border-color: #7f1d1d;
}

.filters-v2 {
  grid-template-columns: minmax(220px, 2fr) repeat(7, minmax(120px, 1fr)) auto auto;
}

.name-input {
  min-width: 240px;
  box-sizing: border-box;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  padding: 9px 10px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .quick-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters-v2 {
    grid-template-columns: 1fr;
  }
}

/* --- dictionaries + auto hint --- */
.notice {
  padding: 14px 16px;
  border: 1px solid #334155;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.08);
  color: #e5e7eb;
  margin: 12px 0 16px;
  line-height: 1.45;
}

.auto-badge {
  display: inline-block;
  min-width: 90px;
  text-align: center;
  padding: 7px 9px;
  border-radius: 999px;
  background: #172554;
  color: #bfdbfe;
  font-weight: 800;
  border: 1px solid #1d4ed8;
}

.auto-badge.warn {
  background: #422006;
  color: #fde68a;
  border-color: #92400e;
}

/* --- bulk edit --- */
.bulk-panel {
  border: 1px solid #334155;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  padding: 16px;
  margin: 18px 0;
}

.bulk-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.bulk-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
}

.bulk-grid input,
.bulk-grid select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 9px 10px;
}

.bulk-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 1100px) {
  .bulk-grid {
    grid-template-columns: 1fr;
  }
}

/* --- person card v2 --- */
.person-header-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: #111827;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.person-header-card h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.person-status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: #172554;
  color: #bfdbfe;
  border: 1px solid #1d4ed8;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.good {
  background: #052e16;
  color: #bbf7d0;
  border-color: #15803d;
}

.status-pill.muted-pill {
  background: #1f2937;
  color: #cbd5e1;
  border-color: #475569;
}

.person-layout-v2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.person-main-column,
.person-side-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.profile-block {
  background: #111827;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 18px;
}

.block-title h2,
.profile-block h2,
.card-form-v2 h2 {
  margin-top: 0;
}

.info-grid.wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.future-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.future-grid div {
  background: #020617;
  border: 1px dashed #475569;
  color: #94a3b8;
  border-radius: 12px;
  padding: 12px;
}

.card-form-v2 {
  position: sticky;
  top: 82px;
}

.compact-block {
  padding: 16px;
}

.side-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-links a {
  display: block;
  padding: 12px;
  border-radius: 12px;
  background: #020617;
  border: 1px solid #334155;
  color: #93c5fd;
  text-decoration: none;
  font-weight: 800;
}

.old-value {
  color: #fca5a5;
}

.new-value {
  color: #86efac;
}

@media (max-width: 1000px) {
  .person-header-card {
    display: block;
  }

  .person-status-badges {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .person-layout-v2 {
    grid-template-columns: 1fr;
  }

  .card-form-v2 {
    position: static;
  }

  .info-grid.wide,
  .future-grid {
    grid-template-columns: 1fr;
  }
}

/* --- extended person form --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #cbd5e1;
  font-weight: 700;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 12px;
  color: #e5e7eb;
  padding: 12px;
  font-size: 15px;
}

.form-grid textarea {
  resize: vertical;
}

@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* --- person card v3 fixes --- */
.card-form-v2 {
  position: static !important;
  top: auto !important;
}

.quick-links-block {
  position: static;
  z-index: 1;
}

.form-grid input:disabled {
  opacity: 0.75;
  color: #94a3b8;
  cursor: not-allowed;
}

.person-side-column {
  align-self: start;
}

/* --- photo + head actions --- */
.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.person-photo-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}

.person-photo {
  width: 220px;
  max-height: 300px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid #334155;
  background: #020617;
}

.photo-controls label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #cbd5e1;
  font-weight: 800;
}

.photo-controls input {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 12px;
  color: #e5e7eb;
  padding: 12px;
}

@media (max-width: 800px) {
  .person-photo-wrap {
    grid-template-columns: 1fr;
  }

  .person-photo {
    width: 100%;
    max-height: 420px;
  }

  .head-actions {
    justify-content: stretch;
  }
}

/* --- BCS battalion / vacancies --- */
.stats-import { grid-template-columns: repeat(7, 1fr); }
.vacancy-row { background: rgba(148, 163, 184, 0.08); }
.vacancy-row .name-input { color: #fde68a; }
.staff-badge { display:inline-block; padding:6px 9px; border-radius:999px; font-weight:800; font-size:12px; white-space:nowrap; border:1px solid #334155; }
.staff-badge.occupied { color:#bbf7d0; background:#052e16; border-color:#166534; }
.staff-badge.vacancy { color:#fde68a; background:#422006; border-color:#92400e; }
.wide-table { min-width: 2150px; }
.bulk-grid { grid-template-columns: repeat(8, minmax(130px, 1fr)); }
.quick-buttons { grid-template-columns: repeat(10, minmax(105px, 1fr)); }
@media(max-width:1100px){.stats-import{grid-template-columns:repeat(2,1fr)}.quick-buttons{grid-template-columns:repeat(2,1fr)}.bulk-grid{grid-template-columns:1fr}}
.stats{grid-template-columns:repeat(7,1fr)}
@media(max-width:800px){.stats{grid-template-columns:repeat(2,1fr)}}


/* --- BCS Excel-like view + subunit selects --- */
.bcs-stats {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.bcs-excel-table {
  min-width: 2600px;
  font-size: 13px;
}

.bcs-excel-table th,
.bcs-excel-table td {
  padding: 7px 8px;
}

.bcs-name-cell {
  min-width: 260px;
  font-weight: 800;
  color: #f8fafc;
}

.unit-group-row td {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #020617 !important;
  color: #93c5fd;
  font-weight: 900;
  letter-spacing: .02em;
  border-top: 2px solid #334155;
  border-bottom: 2px solid #334155;
}

.unit-select {
  min-width: 210px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 9px 10px;
}

.movement-block {
  border-color: #1d4ed8;
}

@media (max-width: 1100px) {
  .bcs-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* Общий БЧС */
.bcs-summary-wrap { max-height: calc(100vh - 260px); overflow: auto; border: 1px solid #d7dee8; border-radius: 14px; background: white; }
.bcs-summary-table { min-width: 1900px; font-size: 12px; }
.bcs-summary-table th { position: sticky; top: 0; z-index: 2; background: #1f2937; color: #fff; text-align: center; }
.bcs-summary-table thead tr:nth-child(2) th { top: 34px; background: #334155; }
.bcs-summary-table td { text-align: center; white-space: nowrap; }
.bcs-summary-table .unit-name { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 210px; }
.bcs-summary-table .summary-total-row td { background: #e5e7eb; font-weight: 700; }
.bcs-summary-table .summary-total-row .unit-name { background: #e5e7eb; }
.bcs-summary-table .summary-level-1 .unit-name { font-weight: 700; }
.bcs-summary-table .summary-level-2 .unit-name { padding-left: 26px; color: #334155; }
.small-note { margin-top: 14px; padding: 12px 14px; }


/* --- Общий БЧС: форма как в Excel-листе БЧС (в,м) --- */
.compact-stats { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.bcs-excel-scroll {
  width: 100%;
  max-height: calc(100vh - 230px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid #111827;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
}
.bcs-excel-summary {
  border-collapse: collapse;
  table-layout: fixed;
  width: max-content;
  min-width: 3600px;
  color: #000;
  font-family: "Times New Roman", Times, serif;
  font-size: 11px;
  background: #fff;
}
.bcs-excel-summary th,
.bcs-excel-summary td {
  border: 1px solid #1f2937;
  padding: 2px 3px;
  height: 20px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.05;
  white-space: nowrap;
}
.bcs-excel-summary thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  font-weight: 700;
  background: #f3f4f6;
}
.bcs-excel-summary thead tr:nth-child(2) th { top: 22px; }
.bcs-excel-summary thead tr:nth-child(3) th { top: 44px; }
.bcs-excel-summary thead tr:nth-child(4) th { top: 66px; }
.bcs-excel-summary thead tr:nth-child(5) th { top: 88px; }
.bcs-excel-summary thead tr:nth-child(6) th { top: 110px; }
.bcs-excel-summary thead tr:nth-child(7) th { top: 132px; }
.bcs-excel-summary thead tr:nth-child(8) th { top: 154px; }
.bcs-excel-summary .bcs-title-cell {
  font-size: 14px;
  background: #fff !important;
}
.bcs-excel-summary .bcs-vertical {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 138px;
  min-width: 26px !important;
  max-width: 34px;
  white-space: normal;
  padding: 5px 1px;
}
.bcs-excel-summary .bcs-unit-cell,
.bcs-excel-summary .bcs-col-unit {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  text-align: left;
  font-weight: 700;
}
.bcs-excel-summary thead .bcs-col-unit { z-index: 6; text-align:center; }
.bcs-excel-summary .bcs-major-row td {
  background: #d9d9d9 !important;
  font-weight: 800;
}
.bcs-excel-summary .bcs-major-row .bcs-unit-cell { background: #d9d9d9 !important; }
.bcs-excel-summary .bcs-col-shtat,
.bcs-excel-summary .bcs-col-spisok,
.bcs-excel-summary .bcs-col-nalitso { background: #f2f2f2; }
.bcs-excel-summary .bcs-col-away { background: #e5e5e5; }
.bcs-excel-summary .bcs-col-lbs { background: #f8dfcf; }
.bcs-excel-summary .bcs-col-prom { background: #fbe6d8; }
.bcs-excel-summary .bcs-col-base { background: #b7d7f0; }
.bcs-excel-summary .bcs-col-tyl { background: #dcefd6; }
.bcs-excel-summary .bcs-col-bng { background: #d9d9d9; }
.bcs-excel-summary .bcs-col-belovodsk { background: #ffe373; }
.bcs-excel-summary tbody td.bcs-col-lbs,
.bcs-excel-summary tbody td.bcs-col-prom { background: #fff7f0; }
.bcs-excel-summary tbody td.bcs-col-base { background: #e9f4ff; }
.bcs-excel-summary tbody td.bcs-col-tyl { background: #f4fbf1; }
.bcs-excel-summary tbody td.bcs-col-belovodsk { background: #fff5bf; }
.bcs-footer-row td {
  border: none !important;
  background: #fff !important;
  font-weight: 700;
  text-align: center !important;
  height: 22px;
}
@media(max-width:900px){
  .compact-stats { grid-template-columns: repeat(2, 1fr); }
  .bcs-excel-summary { font-size: 10px; }
}

/* --- v13 out-of-staff archive --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #001018;
  font-weight: 800;
  text-decoration: none;
  padding: 10px 14px;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: #001018;
}
.btn.danger,
.danger-block .btn.danger {
  background: #dc2626;
  color: #fff;
}
.danger-block {
  border-color: #7f1d1d;
  background: rgba(127, 29, 29, 0.18);
}
.danger-notice {
  border-color: #7f1d1d;
  background: rgba(220, 38, 38, 0.12);
}

/* --- v14 BZ dispatch --- */
.btn.small {
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
  margin-top: 4px;
}
.btn.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.18);
}
.danger-row td {
  background: rgba(220, 38, 38, 0.10) !important;
}
.wide-table input,
.wide-table select,
.wide-table textarea {
  min-width: 130px;
  max-width: 240px;
}

/* v14.1 — выбор людей на БЗ списком как штатка */
.bz-add-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel, #fff);
  padding: 10px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  margin: 12px 0;
}
.bz-roster {
  display: grid;
  gap: 12px;
}
.bz-unit {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  overflow: hidden;
}
.bz-unit summary {
  cursor: pointer;
  padding: 12px 14px;
  background: rgba(0,0,0,.035);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.bz-pick-table td, .bz-pick-table th {
  vertical-align: top;
}
.bz-candidate-ok {
  background: rgba(30, 160, 90, .08);
}
.bz-candidate-warning {
  background: rgba(230, 170, 20, .12);
}
.bz-candidate-blocked {
  background: rgba(210, 60, 60, .10);
}
.bz-candidate-already {
  opacity: .65;
  background: rgba(120, 120, 120, .10);
}
.compact-stats {
  margin: 10px 0 12px;
}
.danger-zone-soft {
  border-color: rgba(210, 60, 60, .25);
}
.success-notice {
  border-color: rgba(30, 160, 90, .35);
  background: rgba(30, 160, 90, .10);
}
