html, body { min-height: 100%; }
body { font-size: 14px; line-height: 1.5; background: #f8fafc; }

.diagnostic-log {
  min-height: 12rem;
  max-height: 26rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mainbody { min-height: calc(100vh - 140px); }
.page-header { border-bottom: 1px solid #d6e4f0; padding-bottom: 0.75rem; }
.adjustImage { border: 1px solid #000; text-align: center; width: auto; margin: 0 auto; }
.adjustImage img { max-width: 200px; max-height: 200px; border: 1px solid #000; }
.textContainer { width: 100%; padding-top: 10px; }
.footer { margin: 0; }
.copyright { text-align: center; }
.required { color: #ff0039; }
.app-actions-column { width: 280px; }
.page-icon-trading { width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: -0.15em; }
.trading-sidebar-desktop { min-height: 460px; }

.trading-sidebar-logo {
  width: auto;
  max-width: 100%;
  height: auto !important;
  max-height: 70px;
  object-fit: contain;
  object-position: left center;
}

.trading-sidebar-logo-link {
  flex: 0 0 auto;
  max-width: 100%;
  overflow: hidden;
}

.smart-sidebar-brand {
  min-height: 70px;
}

.trading-sidebar > .d-flex:first-child {
  max-width: 100%;
  justify-content: flex-start !important;
}

.trading-settings-icon { font-size: 1.31em; }
.trading-refresh-icon {
  font-size: 1.43em;
  position: relative;
  top: 0.04em;
}

.dropdown-menu,
.dropdown-menu-dark {
  --bs-dropdown-bg: #fff;
  --bs-dropdown-color: #212529;
  --bs-dropdown-link-color: #212529;
  --bs-dropdown-link-hover-color: #212529;
  --bs-dropdown-link-hover-bg: #e9ecef;
  --bs-dropdown-link-active-color: #212529;
  --bs-dropdown-link-active-bg: #e9ecef;
  --bs-dropdown-border-color: rgba(0, 0, 0, 0.15);
  --bs-dropdown-divider-bg: rgba(0, 0, 0, 0.12);
  background: #fff !important;
}

.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item.active,
.dropdown-item:active {
  background: #e9ecef !important;
  color: #212529 !important;
}

.trading-sidebar .nav-pills .nav-link {
  color: #212529;
}

.trading-sidebar-menu-toggle {
  border: 0;
  background: transparent;
  text-align: left;
}

.trading-sidebar-submenu {
  margin: .15rem 0 .25rem;
  padding-left: 1.15rem;
}

.trading-sidebar-submenu .nav-link {
  padding-top: .35rem;
  padding-bottom: .35rem;
  font-size: .94em;
}

.trading-sidebar-submenu-chevron {
  font-size: .78em;
  transition: transform .2s ease;
}

.trading-sidebar-menu-toggle[aria-expanded="true"] .trading-sidebar-submenu-chevron {
  transform: rotate(180deg);
}

.trading-mobile-toolbar {
  min-height: 72px;
}

.trading-sidebar-offcanvas {
  width: min(86vw, 320px) !important;
}

.trading-sidebar .nav-pills .nav-link:hover,
.trading-sidebar .nav-pills .nav-link:focus,
.trading-sidebar .nav-pills .nav-link.active,
.trading-sidebar .nav-pills .show > .nav-link {
  background: #e9ecef !important;
  color: #212529 !important;
}

.navbar .nav-link,
.navbar .dropdown-item {
  transition: background-color .2s ease, color .2s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus,
.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
  background: #fff;
  color: #111 !important;
  border-radius: .375rem;
}

.navbar .navbar-nav .nav-link.dropdown-toggle:hover,
.navbar .navbar-nav .nav-link.dropdown-toggle:focus {
  background: transparent;
  color: #fff !important;
}

.navbar .nav-link.dropdown-toggle.show {
  background: transparent;
  color: rgba(255, 255, 255, 0.55) !important;
}

.navbar .dropdown-menu {
  --bs-dropdown-bg: #fff;
  --bs-dropdown-color: #212529;
  --bs-dropdown-link-color: #212529;
  --bs-dropdown-link-hover-color: #212529;
  --bs-dropdown-link-hover-bg: #e9ecef;
  --bs-dropdown-link-active-color: #212529;
  --bs-dropdown-link-active-bg: #dde1e6;
  --bs-dropdown-border-color: rgba(0, 0, 0, 0.15);
  --bs-dropdown-divider-bg: rgba(0, 0, 0, 0.12);
}

.navbar .dropdown-item {
  border-radius: 0;
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus,
.navbar .dropdown-item.active {
  background: #e9ecef;
  color: #212529 !important;
}

.cookie-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 1080;
  display: none;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
  color: #212529;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(33, 37, 41, 0.16);
  border-radius: 0.75rem;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.18);
}

.cookie-notice.show {
  display: block;
}

.cookie-notice p {
  margin-bottom: 0;
}

.cookie-notice a {
  color: #0d6efd;
  font-weight: 600;
  text-decoration: none;
}

.cookie-notice a:hover,
.cookie-notice a:focus {
  text-decoration: underline;
}

@media (max-width: 575.98px) {
  .cookie-notice {
    right: 0.5rem;
    bottom: 0.5rem;
    left: 0.5rem;
    padding: 0.85rem;
    font-size: 0.88rem;
  }
}

/* Settings > Menus */
#menusAccordion {
  --bs-accordion-btn-padding-x: 1px;
  --bs-accordion-body-padding-x: 1px;
}

#menusAccordion .accordion-button {
  padding-left: var(--bs-accordion-btn-padding-x) !important;
  padding-right: var(--bs-accordion-btn-padding-x) !important;
}

#menusAccordion .accordion-body {
  padding-left: var(--bs-accordion-body-padding-x) !important;
  padding-right: var(--bs-accordion-body-padding-x) !important;
}

#menusAccordion .menus-table-responsive {
  position: absolute !important;
  left: -100000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

#menusAccordion .menus-desktop-table {
  display: block !important;
}

#menusAccordion .menus-mobile-list {
  display: block !important;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  height: 0;
  overflow: visible;
  align-items: start;
}

#menusAccordion .menus-mobile-item {
  display: none !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  overflow: hidden !important;
  background: #e9ecef !important;
  border: 2px solid #6c757d !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

#menusAccordion .menus-mobile-row {
  display: grid !important;
  grid-template-columns: 38% minmax(0, 1fr);
  align-items: start !important;
  column-gap: 12px !important;
  padding: 10px 14px !important;
  border-bottom: 1px solid #d1d6db !important;
  white-space: normal !important;
  word-break: break-word !important;
}

#menusAccordion .menus-mobile-row:nth-child(odd) {
  background: #e9ecef !important;
}

#menusAccordion .menus-mobile-row:nth-child(even) {
  background: #f4f6f8 !important;
}

#menusAccordion .menus-mobile-label {
  display: block !important;
  max-width: none !important;
  color: #6c757d !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
}

#menusAccordion .menus-mobile-value {
  display: block !important;
  min-width: 0 !important;
  color: #5d6b78 !important;
  font-size: 1rem !important;
  line-height: 1.25 !important;
  text-align: right !important;
  overflow-wrap: anywhere !important;
}

#menusAccordion .menus-mobile-value code {
  color: #d63384 !important;
  font-size: 0.92rem !important;
  white-space: normal !important;
}

#menusAccordion .menus-mobile-actions {
  display: block !important;
  padding: 10px 14px !important;
  background: #f4f6f8 !important;
}

#menusAccordion .menus-mobile-actions .menus-mobile-label {
  margin-bottom: 8px !important;
}

#menusAccordion .menus-mobile-action-btn {
  display: block !important;
  width: 100% !important;
  margin: 6px 0 0 0 !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

@media (max-width: 991.98px) {
  #menusAccordion .menus-desktop-table {
    display: none !important;
  }

  #menusAccordion .menus-mobile-list {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 14px;
    height: auto;
    overflow: visible;
  }

  #menusAccordion .menus-mobile-item {
    display: block !important;
  }
}

@media (max-width: 767.98px) {
  .menus-page-modal .modal-dialog {
    width: calc(100% - 12px);
    max-width: calc(100% - 12px);
    margin: 6px auto;
  }

  .menus-page-modal .modal-content {
    max-height: calc(100vh - 12px);
    overflow-y: auto;
  }
}

/* Settings pages: permissions, roles, users */
.settings-tight-page > .col-12 {
  padding-left: 1px !important;
  padding-right: 1px !important;
}

.settings-tight-page .accordion-body {
  padding-left: 1px !important;
  padding-right: 1px !important;
}

.settings-tight-page .card {
  margin-left: 1px !important;
  margin-right: 1px !important;
}

.settings-tight-page .card-body {
  padding-left: 1px !important;
  padding-right: 1px !important;
}

.settings-tight-page .settings-responsive-table-wrap {
  margin-left: 1px !important;
  margin-right: 1px !important;
}

.settings-mode-tabs {
  padding-left: 1px;
  padding-right: 1px;
}

.settings-mode-tabs .nav-link.active {
  font-weight: 700;
}

.settings-mode-content {
  padding-top: 14px;
}

.permissions-user-summary > div {
  min-width: 0;
}

.permissions-user-summary-label {
  padding: 5px 8px;
  color: #6c757d;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #e9ecef;
  border: 1px solid #d1d6db;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}

.permissions-user-summary-value {
  min-height: 38px;
  padding: 7px 8px;
  color: #5d6b78;
  background: #f8f9fa;
  border: 1px solid #d1d6db;
  border-radius: 0 0 6px 6px;
  overflow-wrap: anywhere;
}

.permissions-right-switch-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 32px;
  padding-left: 0;
}

.permissions-right-switch {
  float: none !important;
  width: 42px !important;
  height: 22px;
  margin: 0 !important;
  cursor: pointer;
  background-color: #adb5bd;
  border-color: #adb5bd;
}

.permissions-right-switch:checked {
  background-color: #198754;
  border-color: #198754;
}

.permissions-right-switch:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.18rem rgba(25, 135, 84, 0.18);
}

.permissions-right-switch-label {
  min-width: 24px;
  color: #5d6b78;
  font-weight: 700;
  line-height: 1;
}

.settings-responsive-table td[data-label] {
  vertical-align: middle;
}

.settings-responsive-table .settings-actions {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .settings-responsive-table-wrap {
    overflow-x: visible !important;
  }

  .settings-responsive-table {
    display: block;
    width: 100%;
  }

  .settings-responsive-table thead {
    display: none;
  }

  .settings-responsive-table tbody {
    display: block;
    width: 100%;
  }

  .settings-responsive-table tr {
    display: block;
    width: 100%;
    margin: 0 0 14px 0;
    overflow: hidden;
    background: #e9ecef;
    border: 2px solid #6c757d;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  }

  .settings-responsive-table td[data-label] {
    display: grid;
    grid-template-columns: 38% minmax(0, 1fr);
    align-items: start;
    column-gap: 12px;
    min-height: 48px;
    padding: 10px 14px !important;
    border-bottom: 1px solid #d1d6db;
    text-align: right !important;
    color: #5d6b78;
    white-space: normal;
    word-break: break-word;
  }

  .settings-responsive-table td.settings-value-left {
    text-align: left !important;
  }

  .settings-responsive-table td[data-label]:nth-child(odd) {
    background: #e9ecef;
  }

  .settings-responsive-table td[data-label]:nth-child(even) {
    background: #f4f6f8;
  }

  .settings-responsive-table td[data-label]::before {
    content: attr(data-label);
    color: #6c757d;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .settings-responsive-table td[data-label] code {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .settings-responsive-table td.settings-actions {
    display: block;
    padding: 10px 14px !important;
    background: #f4f6f8;
    text-align: left !important;
  }

  .settings-responsive-table td.settings-actions::before {
    display: block;
    margin-bottom: 8px;
  }

  .settings-responsive-table .permissions-right-switch-wrap {
    width: 100%;
    justify-content: flex-end;
  }

  .settings-responsive-table .settings-action-btn,
  .settings-responsive-table .settings-actions form {
    display: block !important;
    width: 100% !important;
    margin: 6px 0 0 0 !important;
  }

  .settings-responsive-table .settings-action-btn {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}
.smart-device-update-cell time {
  display: inline-block;
  padding: .1rem .3rem;
  border-radius: .25rem;
  transition: background-color .2s ease, color .2s ease;
}

.smart-device-status-offline { background-color: rgba(220, 53, 69, .2); }
.smart-rssi { display: inline-flex; align-items: center; gap: .5rem; }
.smart-rssi-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; }
.smart-rssi-bar { display: block; width: 4px; background-color: #ced4da; border-radius: 2px 2px 0 0; }
.smart-rssi-bar:nth-child(1) { height: 4px; }
.smart-rssi-bar:nth-child(2) { height: 7px; }
.smart-rssi-bar:nth-child(3) { height: 10px; }
.smart-rssi-bar:nth-child(4) { height: 14px; }
.smart-rssi-bar:nth-child(5) { height: 18px; }
.smart-rssi-level-1 .smart-rssi-bar:nth-child(-n+1) { background-color: #dc3545; }
.smart-rssi-level-2 .smart-rssi-bar:nth-child(-n+2) { background-color: #fd7e14; }
.smart-rssi-level-3 .smart-rssi-bar:nth-child(-n+3) { background-color: #0d6efd; }
.smart-rssi-level-4 .smart-rssi-bar:nth-child(-n+4),
.smart-rssi-level-5 .smart-rssi-bar:nth-child(-n+5) { background-color: #198754; }
.smart-device-flash-online { animation: smart-device-online-pulse 1.2s ease-out; }
.smart-device-flash-offline { animation: smart-device-offline-pulse 1.2s ease-out; }

@keyframes smart-device-online-pulse {
  0%, 100% { background-color: transparent; color: inherit; }
  35% { background-color: #198754; color: #fff; }
}

@keyframes smart-device-offline-pulse {
  0%, 100% { background-color: rgba(220, 53, 69, .2); color: inherit; }
  35% { background-color: #dc3545; color: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  .smart-device-flash-online, .smart-device-flash-offline { animation-duration: .35s; }
}
