/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--border-radius);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition-smooth);
  border: 1px solid transparent; gap: 8px;
  white-space: nowrap; flex-shrink: 0;
}
.btn-primary {
  background: var(--accent-primary); color: var(--bg-primary);
}
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-secondary); color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--border-accent); }

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}
.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-md); }

.card-header {
  padding: 16px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.card-section { padding: 16px; }
.card-section-tight { padding-top: 0; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 500;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }

.badge.online { background: var(--status-online-dim); color: var(--status-online); border-color: var(--status-online-dim); }
.badge.online .dot { background: var(--status-online); }
.badge.offline { background: var(--status-offline-dim); color: var(--status-offline); border-color: var(--status-offline-dim); }
.badge.offline .dot { background: var(--status-offline); }
.badge.dormant { background: var(--status-dormant-dim); color: var(--status-dormant); border-color: var(--status-dormant-dim); }
.badge.dormant .dot { background: var(--status-dormant); }
.badge.pending { background: rgba(96, 165, 250, 0.08); color: var(--status-pending); border-color: rgba(96, 165, 250, 0.15); }
.badge.pending .dot { background: var(--status-pending); }
.badge.accent { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-color); }

/* Inputs */
.input-group label {
  display: block; font-size: 0.75rem; font-weight: 500;
  color: var(--text-muted); margin-bottom: 6px;
}
.input {
  width: 100%; padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  display: block;
  min-width: 0;
  font-size: 0.875rem; transition: all var(--transition-smooth);
}
.input:focus { border-color: var(--text-muted); outline: none; background: var(--bg-card); }

/* Tables  */
.table-wrapper { width: 100%; min-width: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th {
  padding: 12px 16px; font-size: 0.75rem; font-weight: 500;
  color: var(--text-muted); border-bottom: 1px solid var(--border-color);
}
.table td {
  padding: 14px 16px; font-size: 0.81rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  vertical-align: middle;
  transition: background-color var(--transition-fast);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card-hover); color: var(--text-primary); }
.table-cell-truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.page-heading {
  min-width: 0;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.page-title-meta {
  font-weight: 400;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.page-search {
  flex: 1 1 220px;
  max-width: 320px;
}

.page-search-field {
  flex: 0 0 150px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.detail-rows {
  display: flex;
  flex-direction: column;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.detail-value {
  min-width: 0;
  color: var(--text-primary);
  text-align: right;
  overflow-wrap: anywhere;
}

.tab-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.table-filter-row {
  padding: 0 16px 16px;
}

.section-status {
  padding: 0 16px 16px;
}

.section-status-top {
  padding-top: 8px;
}

.table-checkbox-col {
  width: 36px;
}

.compact-empty-state {
  padding: 32px;
}

/* Toasts */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 16px; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: var(--border-radius);
  color: var(--text-primary); font-size: 0.81rem;
  box-shadow: var(--shadow-lg); min-width: 200px;
}
.toast.success { border-color: rgba(74, 222, 128, 0.25); color: var(--status-online); }
.toast.error   { border-color: rgba(248, 113, 113, 0.25); color: var(--status-offline); }
.toast.warning { border-color: rgba(251, 191, 36, 0.25);  color: var(--status-dormant); }
.toast.info    { border-color: var(--border-accent); }

/* Loading */
.loading-overlay {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; gap: 16px; color: var(--text-muted); font-size: 0.875rem;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px; text-align: center; color: var(--text-muted);
}
.empty-icon { margin-bottom: 12px; opacity: 0.3; }

@media (max-width: 900px) {
  .page-actions,
  .tab-toolbar {
    width: 100%;
  }

  .page-search {
    max-width: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .detail-value {
    text-align: left;
  }
}
