:root {
  --app-bg: #f4f6f8;
  --app-nav: #16324f;
}

body {
  background: var(--app-bg);
}

.app-nav {
  background: var(--app-nav);
}

.icmp-stats {
  flex-wrap: wrap;
}

.icmp-stat {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.icmp-stat span {
  margin-left: 0.15rem;
}

.icmp-stat-online {
  color: #8ee4b5;
}

.icmp-stat-offline {
  color: #ffb4b4;
}

.icmp-stat:hover {
  background: rgba(255, 255, 255, 0.16);
}

.icmp-stat.is-active {
  color: #fff;
}

.icmp-stat-online.is-active {
  background: #198754;
}

.icmp-stat-offline.is-active {
  background: #dc3545;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #16324f, #2b6a8a);
}

.login-card {
  width: min(420px, calc(100% - 2rem));
}

.app-table-wrap {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

#devices-table {
  min-width: 0;
  width: 100%;
}

#devices-table th.col-hidden,
#devices-table td.col-hidden {
  display: none;
}

.columns-menu {
  min-width: 260px;
  max-height: min(70vh, 480px);
  overflow-x: hidden;
  overflow-y: auto;
}

.columns-list .form-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.45rem;
  margin: 0;
  min-height: 1.75rem;
}

.columns-list .form-check-input {
  position: static;
  float: none;
  margin: 0;
  flex: 0 0 1.15em;
  width: 1.15em;
  height: 1.15em;
}

.columns-list .form-check-label {
  margin: 0;
  line-height: 1.2;
}

#devices-table thead th {
  position: sticky;
  top: 0;
  background: #eef3f7;
  z-index: 1;
  white-space: nowrap;
  font-size: 0.8rem;
}

#devices-table thead th.th-sort {
  cursor: pointer;
  user-select: none;
}

#devices-table thead th.th-sort:hover,
#devices-table thead th.th-sort:focus {
  background: #e2ebf2;
  outline: none;
}

#devices-table thead th.th-sort.is-active {
  color: #16324f;
}

.th-sort-ind {
  display: inline-block;
  margin-left: 0.15rem;
  font-size: 0.7rem;
  opacity: 0.35;
  vertical-align: 0.05em;
}

#devices-table thead th.th-sort.is-active .th-sort-ind {
  opacity: 1;
}

#devices-table td {
  font-size: 0.875rem;
  max-width: 220px;
}

#devices-table tbody tr.device-stale {
  background-color: #fff3cd;
}

#devices-table tbody tr.device-stale:hover {
  background-color: #ffe69c;
}

#devices-table td.cell-stale {
  font-weight: 600;
  color: #9a3412;
  white-space: nowrap;
}

.stale-mark {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9a3412;
  background: #fde68a;
}

.cell-clip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-field {
  position: relative;
}

.search-field #search {
  padding-right: 1.85rem;
}

.search-clear {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: #6c757d;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.search-clear:not([hidden]) {
  display: inline-flex;
}

.search-clear:hover {
  color: #212529;
  background: rgba(0, 0, 0, 0.06);
}

.thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  background: #e9ecef;
}

.icmp-up,
.icmp-down,
.icmp-unknown {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

.icmp-up { color: #198754; }
.icmp-down { color: #dc3545; }
.icmp-unknown { color: #6c757d; }

.icmp-history-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.icmp-history-btn:hover .icmp-up,
.icmp-history-btn:hover .icmp-down,
.icmp-history-btn:hover .icmp-unknown {
  text-decoration: underline;
}

.ping-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: #e9ecef;
}

.ping-bar-seg {
  display: block;
  min-width: 1px;
  height: 100%;
}

.ping-bar-up { background: #198754; }
.ping-bar-down { background: #dc3545; }

.ping-hist-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  padding: 0.4rem 0;
  border-top: 1px solid #eef1f4;
  font-size: 0.875rem;
}

.ping-hist-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

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

.device-modal-dialog {
  max-width: min(1100px, calc(100vw - 1rem));
  margin: 0.5rem auto;
  max-height: calc(100dvh - 1rem);
}

.device-modal-dialog .modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 1rem);
  min-height: 0;
  overflow: hidden;
}

#device-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}

#device-modal .modal-header,
#device-modal .modal-footer {
  flex: 0 0 auto;
}

#device-modal .form-label {
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
}

#device-modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.photo-drop {
  border: 2px dashed #c5d0da;
  border-radius: 0.5rem;
  padding: 0.55rem;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  min-height: 96px;
}

.photo-drop.dragover {
  border-color: #0d6efd;
  background: #eef5ff;
}

.photo-drop img {
  max-height: 72px;
  max-width: 100%;
  border-radius: 0.4rem;
  margin-bottom: 0.4rem;
}

.photo-drop #photo-hint i {
  font-size: 1.75rem;
  color: #6c757d;
}

.devices-pager-bar .pagination {
  margin: 0;
}

.devices-pager-bar .page-link {
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
}

.type-cell,
.type-icon-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.type-icon {
  font-size: 1.05em;
  color: #16324f;
}

.type-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.type-icon-choice {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid #d7dee6;
  border-radius: 0.4rem;
  background: #fff;
  color: #16324f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.type-icon-choice:hover {
  background: #eef5ff;
  border-color: #0d6efd;
}

.type-icon-choice.is-active {
  background: #16324f;
  border-color: #16324f;
  color: #fff;
}

.type-icon-choice.is-active .type-icon {
  color: #fff;
}

.copyable {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
}

.copyable code {
  font-size: 0.85em;
}

.copy-btn {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: #8a96a3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex: 0 0 auto;
}

.copy-btn:hover {
  color: #16324f;
  background: rgba(22, 50, 79, 0.08);
}

.copy-btn.is-copied {
  color: #198754;
  background: rgba(25, 135, 84, 0.1);
}

td.mac-alert {
  background: #fff3cd;
  box-shadow: inset 3px 0 0 #dc3545;
}

.mac-seen {
  font-size: 0.75rem;
  color: #b02a37;
  margin-top: 0.15rem;
}

.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.6rem;
}

.link-chip,
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eef3f8;
  font-size: 0.8rem;
  line-height: 1.3;
}

.link-chip code {
  font-size: 0.75em;
}

.link-chip-x {
  border: 0;
  background: transparent;
  color: #6c757d;
  padding: 0 0.1rem;
  line-height: 1;
}

.link-chip-x:hover {
  color: #dc3545;
}

.link-suggest {
  position: relative;
  z-index: 5;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 0.2rem;
}

.link-suggest .type-icon {
  font-size: 0.95em;
}
