/* ---------- Favourites ---------- */
.favs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px 0;
  max-width: 1400px;
  margin: 0 auto;
}
.fav {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  height: 46px;
  padding: 0 14px 0 7px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition:
    transform 0.15s,
    border-color 0.15s,
    background 0.15s;
}
a.fav:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--card-hover);
}
a.fav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.fav .icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 18px;
}
.fav .icon .letter {
  font-size: 14px;
}
.fav-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav .drag-handle {
  width: 16px;
  height: 30px;
  margin: 0 -4px 0 0;
  align-self: center;
}
.fav .icon-btn.sm {
  width: 26px;
  height: 26px;
  margin-right: -8px;
}
.dot.up {
  background: var(--green);
}
.dot.down {
  background: var(--red);
}
.dot.warn {
  background: var(--amber);
}
.icon-btn.on {
  color: var(--amber);
}
.icon-btn.on svg {
  fill: currentColor;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px 48px;
}

/* ---------- Server header ---------- */
/* Header on the left, host stats on the right; they stack when there isn't room. */
.server-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  padding: 16px 0 18px;
}
.server-head {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 12px 20px;
  min-width: 0;
}
.server-head .server-icon {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  font-size: 30px;
  align-self: flex-start;
}
.server-head .info {
  flex: 1;
  min-width: 220px;
}
.server-head h2 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.server-head .desc {
  margin: 4px 0 0;
  color: var(--muted);
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
a.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.chip svg {
  width: 13px;
  height: 13px;
}
.chip .dot {
  background: currentColor;
}
.chip.green {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
}
.chip.red {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
}
.chip.amber {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 35%, transparent);
}
.chip button {
  all: unset;
  cursor: pointer;
  display: inline-flex;
}
/* Routine freshness stays quiet; only stale or unreachable data calls for attention. */
.chip.age {
  font-weight: 500;
  color: var(--muted);
  background: var(--card);
  border-color: var(--border);
}
.chip.age svg {
  width: 14px;
  height: 14px;
}
.chip.age.amber {
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 16%, var(--card));
  border-color: color-mix(in srgb, var(--amber) 55%, transparent);
}
.chip.age.red {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 16%, var(--card));
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

/* ---------- Groups ---------- */
.services {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 10px;
  padding: 4px 2px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
button.group-head {
  cursor: pointer;
}
button.group-head:hover {
  color: var(--text);
}
button.group-head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.group-head svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}
.group.collapsed .group-head svg {
  transform: rotate(-90deg);
}
.group.collapsed .group-head {
  margin-bottom: 0;
}
.group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-head .count {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--border);
  letter-spacing: 0;
}
.group-head .drag-handle {
  width: 22px;
  height: 28px;
  margin-left: -4px;
  align-self: center;
}
.group-usage {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.group-usage .usage-label:not(:first-child) {
  margin-left: 6px;
}
body.editing .group.named {
  padding: 10px 12px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
}

/* ---------- Service cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition:
    transform 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--card-hover);
}
.card .main-link {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}
.card button.main-link {
  all: unset;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
  cursor: pointer;
}
.card .main-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card .top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.card .name {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.card .description {
  margin: 7px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.card .text > .status {
  margin-top: 7px;
}
.card .links a.chip {
  min-height: 32px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.card .links .link-label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.card .links :is(svg, .icon-btn) {
  flex-shrink: 0;
}
.card .links .primary-link {
  color: var(--text);
  border-color: var(--border-strong);
  font-weight: 600;
}
.card .text {
  flex: 1;
  min-width: 0;
}
.card .links {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
  z-index: 2;
  margin-top: auto;
}
.card .server-tag {
  overflow-wrap: anywhere;
  font-size: 0.72rem;
  color: var(--accent-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.card .edit-tools {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 4px;
}
/* Slightly quieter typography and actions in Cards layout. */
body[data-layout="cards"] #services .card {
  font-size: 0.92rem;
}
body[data-layout="cards"] #services .card .name {
  font-size: 0.92rem;
}
body[data-layout="cards"] #services .card .description {
  font-size: 0.8rem;
}
body[data-layout="cards"] #services .card :is(.status, .chip, .usage-item) {
  font-size: 0.7rem;
}
body[data-layout="cards"] #services .card .server-tag {
  font-size: 0.68rem;
}
body[data-layout="cards"] #services .card .usage-label {
  font-size: 0.62rem;
}
body[data-layout="cards"] #services .card .icon {
  font-size: 22px;
}
body[data-layout="cards"] #services .card .icon .letter {
  font-size: 18px;
}
body[data-layout="cards"] #services .card .links a.chip {
  min-height: 28px;
  padding: 3px 8px;
  gap: 5px;
}
body[data-layout="cards"] #services .card .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
body[data-layout="cards"] #services .card :is(.links, .edit-tools) svg {
  width: 14px;
  height: 14px;
}
@media (pointer: coarse) {
  body[data-layout="cards"] #services .card :is(.links a.chip, .icon-btn) {
    min-width: 44px;
    min-height: 44px;
  }
}
.card.add-card {
  align-items: center;
  justify-content: center;
  min-height: 120px;
  cursor: pointer;
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
}
.card.add-card:hover {
  color: var(--text);
  border-color: var(--accent);
}

.icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  font-size: 24px;
  line-height: 1;
}
.icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}
.icon .letter {
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray);
  flex-shrink: 0;
}
.status.up {
  color: var(--green);
}
.status.up .dot {
  background: var(--green);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent);
  animation: pulse 2s infinite;
}
.status.down {
  color: var(--red);
}
.status.down .dot {
  background: var(--red);
}
.status.warn {
  color: var(--amber);
}
.status.warn .dot {
  background: var(--amber);
}
@keyframes pulse {
  70% {
    box-shadow: 0 0 0 7px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

