html {
  min-height: 100%;
  background: var(--brand-surface-muted);
}

body {
  min-height: 100vh;
  background: var(--brand-surface-muted);
  color: var(--brand-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}

a:hover {
  color: var(--brand-primary-hover);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--brand-text);
  font-weight: 650;
}

.text-purple,
.text-primary {
  color: var(--brand-primary) !important;
}

.text-muted {
  color: var(--brand-text-muted) !important;
}

.top-nav {
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  padding: 10px 0;
}

.top-nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.top-nav .brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.top-nav .brand img {
  display: block;
  width: auto;
  height: 52px;
  max-width: 100%;
  object-fit: contain;
}

.top-nav .auth-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.top-nav .auth-links a {
  margin-left: 0;
}

.city-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.city-selector .badge {
  cursor: pointer;
  background: var(--brand-surface-muted);
  color: var(--brand-text-muted);
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 500;
  padding: 6px 10px;
}

.btn {
  border-radius: 8px;
  font-weight: 550;
  min-height: 38px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn-sm {
  border-radius: 7px;
  min-height: 34px;
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-on-primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.btn-primary:disabled,
.btn-primary.disabled,
.show > .btn-primary.dropdown-toggle {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: var(--brand-on-primary);
}

.btn-outline-primary {
  background: var(--brand-surface);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active,
.btn-outline-primary.active,
.show > .btn-outline-primary.dropdown-toggle {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-on-primary);
}

.btn-outline-secondary {
  background: var(--brand-surface);
  border-color: var(--brand-neutral);
  color: var(--brand-text-muted);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
  background: var(--brand-surface-muted);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-silver {
  background: var(--brand-neutral-light);
  border: 1px solid var(--brand-neutral);
  color: var(--brand-text);
}

.btn-silver:hover {
  background: var(--brand-neutral);
}

.btn:focus-visible,
a:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--brand-focus);
  box-shadow: 0 0 0 .2rem rgba(139, 114, 179, .18);
  outline: 0;
}

.form-control,
.form-select {
  border-color: var(--brand-border);
  border-radius: 8px;
  color: var(--brand-text);
}

.form-control::placeholder {
  color: var(--brand-neutral-dark);
}

.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.form-label {
  color: var(--brand-text-muted);
  font-weight: 500;
}

.card {
  background: var(--brand-surface);
  border-color: var(--brand-border);
  border-radius: 12px;
}

.card.border-purple {
  border-color: var(--brand-purple-light);
}

.card-header {
  border-bottom-color: var(--brand-border);
}

.card-header.bg-white {
  background: var(--brand-surface) !important;
}

.shadow-sm {
  box-shadow: 0 2px 10px rgba(34, 34, 34, .045) !important;
}

.border,
.border-top,
.border-bottom,
.border-start,
.border-end {
  border-color: var(--brand-border) !important;
}

.table {
  color: var(--brand-text);
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--brand-border);
}

.table-light,
.table-light > th,
.table-light > td {
  background: var(--brand-surface-muted);
  color: var(--brand-text-muted);
}

.table-hover > tbody > tr:hover > * {
  background: rgba(187, 169, 209, .12);
  color: var(--brand-text);
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

.nav-tabs {
  border-bottom-color: var(--brand-border);
  gap: 4px;
}

.nav-tabs .nav-link {
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--brand-text-muted);
}

.nav-tabs .nav-link:hover {
  border-color: var(--brand-border);
  color: var(--brand-primary);
}

.nav-tabs .nav-link.active {
  background: var(--brand-surface);
  border-color: var(--brand-border);
  border-bottom-color: var(--brand-surface);
  color: var(--brand-primary);
  font-weight: 600;
}

.modal-content {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  box-shadow: 0 16px 45px rgba(34, 34, 34, .16);
}

.modal-header,
.modal-footer {
  border-color: var(--brand-border);
}

.modal-backdrop.show {
  opacity: .45;
}

.dropdown-menu {
  border-color: var(--brand-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(34, 34, 34, .1);
}

.dropdown-item {
  color: var(--brand-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(187, 169, 209, .16);
  color: var(--brand-primary);
}

.dropdown-item.active,
.dropdown-item:active {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}

.list-group-item {
  border-color: var(--brand-border);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
  background: rgba(187, 169, 209, .12);
  color: var(--brand-primary);
}

.progress {
  background: var(--brand-neutral-light);
}

.progress-bar,
.bg-purple {
  background-color: var(--brand-primary) !important;
}

.ue-dash-header {
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  padding: 14px 0;
  margin: 0 0 1.25rem;
}

.ue-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ue-role-badge {
  background: rgba(187, 169, 209, .2);
  color: var(--brand-primary);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 600;
}

.ue-dash-title {
  color: var(--brand-text);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.btn-ue-ghost {
  background: var(--brand-surface);
  border: 1px solid var(--brand-purple-light);
  color: var(--brand-primary);
}

.btn-ue-ghost:hover {
  background: rgba(187, 169, 209, .18);
  color: var(--brand-primary-hover);
}

.navbar-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--brand-border);
  display: none;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 1000;
  box-shadow: 0 -2px 12px rgba(34, 34, 34, .05);
}

.navbar-bottom a,
.navbar-bottom button {
  color: var(--brand-text-muted);
  text-decoration: none;
  font-size: 11px;
  text-align: center;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.15;
}

.navbar-bottom button {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
}

.navbar-bottom .web-push-mobile::after {
  content: "Пуш";
  display: block;
  font-size: 10px;
}

.navbar-bottom a.active,
.navbar-bottom button[data-active="1"] {
  color: var(--brand-primary);
}

.navbar-bottom i {
  display: block;
  height: 24px;
  font-size: 22px;
  line-height: 24px;
  margin-bottom: 0;
}

.navbar-bottom span {
  display: block;
  font-size: 10px;
}

.mobile-more-menu {
  height: auto;
  max-height: 85vh;
  border-radius: 16px 16px 0 0;
}

.mobile-more-links {
  display: flex;
  flex-direction: column;
}

.mobile-more-links a,
.mobile-push-setting {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 8px;
  border: 0;
  border-bottom: 1px solid var(--brand-border);
  background: none;
  color: var(--brand-text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

.mobile-more-links i {
  width: 24px;
  flex: 0 0 24px;
  font-size: 20px;
  text-align: center;
  color: var(--brand-primary);
}

.mobile-push-setting {
  min-height: 0;
}

.mobile-push-setting[data-active="0"],
.mobile-push-setting[data-active="1"] {
  color: #fff;
  border-radius: 8px;
}
.mobile-push-setting[data-active="0"] { background: #dc3545; }
.mobile-push-setting[data-active="1"] { background: #198754; }
.mobile-push-setting[data-active] i { color: #fff; }

.mobile-more-links .mobile-logout {
  color: #c0392b;
  border-bottom: 0;
}

@media (max-width: 767px) {
  body {
    font-size: 14px;
  }

  .top-nav {
    padding: 8px 0;
  }

  .top-nav .container {
    justify-content: center;
  }

  .top-nav .brand {
    width: 100%;
    justify-content: center;
  }

  .top-nav .brand img {
    height: 42px;
  }

  .top-nav .container {
    position: relative;
  }

  .top-nav .auth-links {
    display: contents;
  }

  .top-nav .auth-links > *:not(#webPushButton):not(.install-app-button):not(.staff-logout-button) {
    display: none !important;
  }

  .top-nav .install-app-button,
  .top-nav #webPushButton {
    display: inline-flex !important;
    position: absolute;
    top: 4px;
    min-height: 36px;
    padding: .35rem .5rem;
  }

  .top-nav .install-app-button {
    left: 8px;
  }

  .top-nav #webPushButton {
    right: 8px;
    min-height: 32px;
    padding: .3rem .45rem;
    font-size: 11px;
    white-space: nowrap;
  }

  .top-nav #webPushButton > span.ms-1 {
    display: none;
  }

  .top-nav #webPushButton::after {
    content: "Push";
    margin-left: .25rem;
  }

  .top-nav .staff-logout-button {
    display: inline-flex !important;
    position: absolute;
    top: 52px;
    right: 8px;
    min-height: 32px;
    padding: .25rem .5rem;
  }

  .top-nav .city-selector {
    flex-grow: 0;
    justify-content: center;
  }

  #ownerTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #ownerTabs .nav-link {
    white-space: nowrap;
  }

  .navbar-bottom {
    display: flex;
  }

  .btn {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 38px;
  }

  .form-control,
  .form-select {
    min-height: 44px;
  }

  .ue-dash-title {
    font-size: 1.2rem;
  }

  .nav-tabs {
    flex-wrap: wrap;
    gap: 4px;
  }

  #groups {
    min-width: 0;
    overflow-x: hidden;
  }

  #groups .d-flex.gap-2 {
    flex-wrap: wrap;
    max-width: 100%;
  }

  #groups .d-flex.gap-2 > .btn {
    flex: 0 0 auto;
    max-width: 100%;
  }

  #groups .card {
    min-width: 0;
    max-width: 100%;
  }

  #groups .table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.attendance-days-options {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.attendance-day-option {
  position: relative;
  display: inline-flex;
  margin: 0;
  cursor: pointer;
}

.attendance-day-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.attendance-day-option span {
  min-width: 48px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem .75rem;
  border: 1px solid var(--brand-border);
  border-radius: .5rem;
  background: var(--brand-surface);
  color: var(--brand-text);
  font-weight: 600;
  transition: background-color .15s, border-color .15s, color .15s;
}

.attendance-day-input:checked + span {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}

.attendance-day-input:focus-visible + span {
  outline: 3px solid var(--brand-focus);
  outline-offset: 2px;
}

.attendance-day-input:disabled + span {
  opacity: .5;
  cursor: not-allowed;
}
