/* Вид по образцу Minia (ТЗ, 7.1), свой код на Bootstrap 5. */
:root {
  --sp-primary: #5156be;
  --sp-primary-rgb: 81, 86, 190;
  --sp-success: #2ab57d;
  --sp-danger: #fd625e;
  --sp-warning: #ffbf53;
  --sp-info: #4ba6ef;
  --sp-text: #313533;
  --sp-muted: rgba(49, 53, 51, .75);
  --sp-border: #e9e9ef;
  --sp-sidebar: #fbfaff;
  --sp-sidebar-title: #545a6d;
  --sp-body: #fff;

  --bs-primary: var(--sp-primary);
  --bs-primary-rgb: var(--sp-primary-rgb);
  --bs-body-font-family: "IBM Plex Sans", system-ui, sans-serif;
  --bs-body-font-size: .875rem;
  --bs-body-color: var(--sp-text);
  --bs-border-color: var(--sp-border);
  --bs-link-color: var(--sp-primary);
  --bs-link-color-rgb: var(--sp-primary-rgb);
  --bs-link-hover-color: #4549a2;
  --bs-border-radius: .25rem;
}

body { background: var(--sp-body); color: var(--sp-text); }
a { text-decoration: none; }
.text-muted { color: var(--sp-muted) !important; }

/* --- каркас --- */
.sp-sidebar {
  position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 1030;
  background: var(--sp-sidebar); border-right: 1px solid var(--sp-border);
  display: flex; flex-direction: column; transition: transform .2s;
}
.sp-brand {
  height: 70px; display: flex; align-items: center; gap: .6rem; padding: 0 1.5rem;
  font-weight: 600; font-size: 1.05rem; color: var(--sp-text);
}
.sp-brand .logo {
  width: 30px; height: 30px; border-radius: 6px; background: var(--sp-primary); color: #fff;
  display: grid; place-items: center; font-size: 1.1rem;
}
.sp-menu { overflow-y: auto; padding: .5rem 0 2rem; }
.sp-menu .menu-title {
  padding: 1.1rem 1.5rem .5rem; font-size: .75rem; font-weight: 500; letter-spacing: .03em;
  color: var(--sp-sidebar-title); text-transform: uppercase; opacity: .8;
}
.sp-menu a {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; color: var(--sp-sidebar-title);
  font-weight: 500; font-size: .9rem;
}
.sp-menu a i { font-size: 1.15rem; width: 1.2rem; }
.sp-menu a:hover, .sp-menu a.active { color: var(--sp-primary); }
.sp-menu a.active { background: rgba(var(--sp-primary-rgb), .06); }
.sp-menu a .badge { margin-left: auto; }

.sp-topbar {
  position: fixed; top: 0; left: 250px; right: 0; height: 70px; z-index: 1020;
  background: #fff; border-bottom: 1px solid var(--sp-border);
  display: flex; align-items: center; gap: .5rem; padding: 0 1.25rem 0 .75rem;
}
.sp-topbar .icon-btn {
  border: 0; background: none; height: 70px; padding: 0 .75rem; color: var(--sp-text); font-size: 1.3rem;
  display: inline-flex; align-items: center; position: relative;
}
.sp-topbar .icon-btn:hover { color: var(--sp-primary); }
.sp-search { position: relative; }
.sp-search input {
  background: #f3f3f9; border: 0; border-radius: 30px; height: 38px; padding: 0 1rem 0 2.4rem; width: 260px;
}
.sp-search i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--sp-muted); }
.sp-user { display: flex; align-items: center; gap: .6rem; padding: 0 .75rem; height: 70px; border-left: 1px solid var(--sp-border); background: #f9f9fb; }
.sp-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(var(--sp-primary-rgb), .15); color: var(--sp-primary);
  display: grid; place-items: center; font-weight: 600;
}

.sp-main { margin-left: 250px; padding: calc(70px + 1.5rem) 1.5rem 3rem; min-height: 100vh; }
.sp-footer { margin-left: 250px; padding: 1rem 1.5rem; color: var(--sp-muted); border-top: 1px solid var(--sp-border); background: #fff; }

.page-title-box { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title-box h4 { font-size: 1.125rem; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: .02em; }
.breadcrumb { margin: 0; font-size: .85rem; }
.breadcrumb-item.active { color: var(--sp-muted); }

/* --- карточки, таблицы, кнопки --- */
.card { border: 1px solid var(--sp-border); border-radius: .25rem; box-shadow: none; margin-bottom: 1.5rem; }
.card-header { background: #fff; border-bottom: 1px solid var(--sp-border); padding: 1rem 1.25rem; }
.card-title { font-size: .95rem; font-weight: 600; margin: 0; }
.card-body { padding: 1.25rem; }

.table { --bs-table-color: var(--sp-text); margin: 0; }
.table > thead th {
  font-weight: 600; background: #f8f9fa; border-bottom-width: 1px; white-space: nowrap; font-size: .82rem;
}
.table td, .table th { padding: .75rem; vertical-align: middle; border-color: var(--sp-border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--sp-primary-rgb), .03); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn { font-size: .875rem; border-radius: .25rem; }
.btn-primary {
  --bs-btn-bg: var(--sp-primary); --bs-btn-border-color: var(--sp-primary);
  --bs-btn-hover-bg: #4549a2; --bs-btn-hover-border-color: #4549a2;
  --bs-btn-active-bg: #4145988f; --bs-btn-disabled-bg: var(--sp-primary);
  box-shadow: 0 2px 6px 0 rgba(var(--sp-primary-rgb), .5);
}
.btn-soft-primary { background: rgba(var(--sp-primary-rgb), .1); color: var(--sp-primary); border: 0; }
.btn-soft-primary:hover { background: var(--sp-primary); color: #fff; }
.btn-soft-danger { background: rgba(253, 98, 94, .1); color: var(--sp-danger); border: 0; }
.btn-soft-danger:hover { background: var(--sp-danger); color: #fff; }
.btn-light { background: #f3f3f9; border-color: #f3f3f9; }

.badge { font-weight: 500; font-size: .75rem; }
.badge-soft-primary { background: rgba(var(--sp-primary-rgb), .18); color: var(--sp-primary); }
.badge-soft-success { background: rgba(42, 181, 125, .18); color: var(--sp-success); }
.badge-soft-danger { background: rgba(253, 98, 94, .18); color: var(--sp-danger); }
.badge-soft-warning { background: rgba(255, 191, 83, .18); color: #c98a12; }
.badge-soft-info { background: rgba(75, 166, 239, .18); color: var(--sp-info); }
.badge-soft-secondary { background: rgba(116, 120, 141, .18); color: #74788d; }

.form-control, .form-select { font-size: .875rem; border-color: #e2e5e8; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--sp-primary-rgb), .5); box-shadow: none; }
.form-label { font-weight: 500; margin-bottom: .4rem; }
.form-check-input { border-color: #b9bcc8; flex-shrink: 0; }
.form-check-input:checked { background-color: var(--sp-primary); border-color: var(--sp-primary); }
.form-text { color: var(--sp-muted); }
.invalid-feedback { display: block; }
.check-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--sp-border); border-radius: .25rem; padding: .5rem .75rem; }
.check-list div { padding: .15rem 0; }
.check-list ul { list-style: none; padding: 0; margin: 0; }
.check-list li label { display: flex; gap: .5rem; align-items: center; padding: .15rem 0; }

/* мини-карточки чисел, как «My Wallet» */
.stat-card .card-body { display: flex; justify-content: space-between; align-items: center; }
.stat-card .stat-label { color: var(--sp-muted); margin-bottom: .5rem; font-size: .85rem; }
.stat-card .stat-value { font-size: 1.35rem; font-weight: 600; margin: 0; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.4rem;
  background: rgba(var(--sp-primary-rgb), .12); color: var(--sp-primary);
}

/* вкладки карточки объекта */
.nav-tabs-custom { border-bottom: 1px solid var(--sp-border); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; }
.nav-tabs-custom .nav-link {
  border: 0; border-bottom: 2px solid transparent; color: var(--sp-text); font-weight: 500; padding: .75rem 1rem; white-space: nowrap;
}
.nav-tabs-custom .nav-link.active { color: var(--sp-primary); border-bottom-color: var(--sp-primary); background: none; }
.nav-tabs-custom .nav-link.disabled { color: #adb5bd; }
.nav-tabs-custom .nav-link small { font-size: .7rem; }

/* дерево договоров */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 1.4rem; border-left: 1px dashed #c9cbe0; padding-left: 1rem; }
.tree li { position: relative; }
.tree ul > li::before {
  content: ""; position: absolute; left: -1rem; top: 1.55rem; width: .9rem; border-top: 1px dashed #c9cbe0;
}
.tree-node {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .5rem 0;
  padding: .7rem 1rem; border: 1px solid var(--sp-border); border-radius: .25rem; background: #fff;
}
.tree-node.intragroup { background: #fbfaff; border-color: rgba(var(--sp-primary-rgb), .3); }
.tree-node .parties { font-weight: 500; flex: 1 1 320px; }
.tree-node .parties i { color: var(--sp-muted); margin: 0 .25rem; }
.tree-node .meta { color: var(--sp-muted); font-size: .82rem; }

/* переключатель компаний */
.company-switch .dropdown-menu { width: 340px; padding: 0; }
.company-switch .list { max-height: 320px; overflow-y: auto; padding: .25rem 0; }
.company-switch label { display: flex; gap: .6rem; align-items: center; padding: .45rem 1rem; cursor: pointer; margin: 0; }
.company-switch label:hover { background: #f8f9fa; }
.company-switch .label-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* журнал */
.audit-changes { margin: 0; padding: 0; list-style: none; font-size: .82rem; }
.audit-changes li { padding: .1rem 0; }
.audit-changes .old { color: var(--sp-danger); text-decoration: line-through; }
.audit-changes .new { color: var(--sp-success); }

/* вход */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 460px) 1fr; background: #fff; }
.auth-form { padding: 3rem; display: flex; flex-direction: column; justify-content: center; }
.auth-side {
  background: linear-gradient(135deg, #5156be 0%, #3b3f9a 100%); color: #fff; padding: 3rem;
  display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden;
}
.auth-side::before, .auth-side::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .06);
}
.auth-side::before { width: 520px; height: 520px; top: -160px; right: -160px; }
.auth-side::after { width: 300px; height: 300px; bottom: 120px; left: -90px; }
.auth-side h3 { font-weight: 600; position: relative; }
.auth-side p { opacity: .8; position: relative; max-width: 480px; }

.empty { text-align: center; color: var(--sp-muted); padding: 2.5rem 1rem; }
.empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

dl.props { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; gap: .55rem 1rem; margin: 0; }
dl.props dt { font-weight: 400; color: var(--sp-muted); }
dl.props dd { margin: 0; font-weight: 500; }

.sp-backdrop { display: none; }

/* телефон: меню под кнопкой ☰ (ТЗ, раздел 4 — от 360 px) */
@media (max-width: 991.98px) {
  .sp-sidebar { transform: translateX(-100%); }
  body.menu-open .sp-sidebar { transform: none; }
  body.menu-open .sp-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 1025; }
  .sp-topbar, .sp-main, .sp-footer { left: 0; margin-left: 0; }
  .sp-search { display: none; }
  .sp-main { padding: calc(70px + 1rem) 1rem 2rem; }
  .sp-user .who { display: none; }
  .company-switch .dropdown-menu { width: calc(100vw - 2rem); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-form { padding: 2rem 1.25rem; }
}
@media (max-width: 575.98px) {
  .company-switch .label-text { max-width: 120px; }
  .page-title-box { flex-direction: column; align-items: flex-start; }
  .tree ul { margin-left: .4rem; padding-left: .6rem; }
  .tree ul > li::before { left: -.6rem; width: .5rem; }
  .tree-node { padding: .6rem .7rem; }
}

/* тона значков карточек дашборда */
.stat-icon.tone-success { background: rgba(42, 181, 125, .15); color: var(--sp-success); }
.stat-icon.tone-danger { background: rgba(253, 98, 94, .15); color: var(--sp-danger); }
.stat-icon.tone-warning { background: rgba(255, 191, 83, .18); color: #c98a12; }
